Opened 15 years ago
Closed 15 years ago
#963 closed Support Requests (wontfix)
typeof: nested types of BOOST_TYPEOF'ed type don't work on gcc 3.4.5 in native mode
Reported by: | Owned by: | Peder Holt | |
---|---|---|---|
Milestone: | Component: | None | |
Version: | Boost 1.34.0 | Severity: | Problem |
Keywords: | nested typeof gcc | Cc: |
Description
Example:
#include <boost/typeof/typeof.hpp> #include <boost/typeof/std/vector.hpp> BOOST_TYPEOF_REGISTER_TYPE(std::vector<int>::iterator) BOOST_TYPEOF_REGISTER_TYPE(std::vector<int>::const_iterator) int main(int argc, char** argv) { std::vector<int> v; BOOST_TYPEOF(v)::iterator i = v.begin(); return 0; }
Results in an error on gcc-3.4.5
1.cpp:9: error: expected initializer before "i"
This is because apparently you can't do typeof(v)::type in gcc 3.4.5. Workaround is very simple, but maybe it's better if this is implemented in boost.typeof itself:
#include <boost/typeof/typeof.hpp> #include <boost/typeof/std/vector.hpp> BOOST_TYPEOF_REGISTER_TYPE(std::vector<int>::iterator) BOOST_TYPEOF_REGISTER_TYPE(std::vector<int>::const_iterator) template<typename T> struct ut_type_mirror { typedef T type; }; #define UT_TYPEOF(v) ut_type_mirror<BOOST_TYPEOF(v)>::type int main(int argc, char** argv) { std::vector<int> v; UT_TYPEOF(v)::iterator i = v.begin(); return 0; }
Change History (2)
comment:1 by , 15 years ago
Owner: | set to |
---|---|
Severity: | → Showstopper |
comment:2 by , 15 years ago
Resolution: | → wontfix |
---|---|
Severity: | Showstopper → Problem |
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
The above solution was tested and rejected for the following reason: GCC 3.3.3 (which we probably want to support) ICEs if
__typeof__
is wrapped into anything while inside a template: