public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "leonid at volnitsky dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/51989] New: std::deque::iterator recognised as container Date: Wed, 25 Jan 2012 06:59:00 -0000 [thread overview] Message-ID: <bug-51989-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51989 Bug #: 51989 Summary: std::deque::iterator recognised as container Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: leonid@volnitsky.com Created attachment 26450 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26450 deque-bug.cc I need is_container<T> template which would recognize if T is a container. Code below works as expected. With exception for std::deque::iterator - gcc can not compile code below: ------------------------------------------------------------------ #include <iostream> #include <type_traits> #include <vector> #include <list> #include <set> #include <deque> template <typename T> struct is_container { template <typename U> static char test( U* u, typename U::const_iterator b = ((U*)0)->begin(), typename U::const_iterator e = ((U*)0)->end() ); template <typename U> static long test(...); enum { value = sizeof test<T>(0) == 1 }; }; int main() { std::cout << "void\t" << is_container< void >::value << '\n'; std::cout << "int\t" << is_container< int >::value << '\n'; std::cout << "int*\t" << is_container< int* >::value << '\n'; std::cout << "vector<int>\t" << is_container< std::vector<int> >::value << '\n'; std::cout << "deque<int>\t" << is_container< std::deque<int> >::value << '\n'; std::cout << "set<int>::iterator\t" << is_container< std::set<int>::iterator >::value << '\n'; std::cout << "vector<int>::iterator\t" << is_container< std::vector<int>::iterator >::value << '\n'; // gcc error std::cout << "deque<int>::iterator\t" << is_container< std::deque<int>::iterator >::value << '\n'; } ----------------------------------------------------------------------- Compiling it with GCC (4.7.0-alpha20111203): gcc -std=gnu++0x -Wall deque-bug.cc -o deque-bug Produce following error: deque-bug.cc: In instantiation of ‘struct is_container<std::_Deque_iterator<int, int&, int*> >’: deque-bug.cc:31:84: required from here deque-bug.cc:18:7: error: ‘struct std::_Deque_iterator<int, int&, int*>’ has no member named ‘begin’ deque-bug.cc:18:7: error: ‘struct std::_Deque_iterator<int, int&, int*>’ has no member named ‘end’ Attached are source and -save-temps
next reply other threads:[~2012-01-25 5:02 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-01-25 6:59 leonid at volnitsky dot com [this message] 2012-01-25 7:41 ` [Bug c++/51989] " leonid at volnitsky dot com 2012-01-25 8:12 ` leonid at volnitsky dot com 2012-01-25 8:27 ` leonid at volnitsky dot com 2012-01-25 10:16 ` redi at gcc dot gnu.org 2012-01-25 10:26 ` redi at gcc dot gnu.org 2012-01-25 10:42 ` leonid at volnitsky dot com 2012-01-25 12:30 ` redi at gcc dot gnu.org 2012-01-25 12:42 ` leonid at volnitsky dot com 2012-01-25 18:18 ` jason at gcc dot gnu.org 2012-01-25 21:19 ` paolo.carlini at oracle dot com 2012-03-02 16:19 ` paolo at gcc dot gnu.org 2012-04-24 12:13 ` paolo.carlini at oracle dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-51989-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).