[proto] extends example not compiling
Is this example, contained in the boost.Proto manual supposed to compile? #include<complex> #include <boost/proto/core.hpp> #include <boost/proto/context.hpp> #include <boost/proto/debug.hpp> #include<boost/proto/extends.hpp> template<class T, class Dummy = boost::proto::is_proto_expr> struct my_complex { BOOST_PROTO_EXTENDS( typename boost::proto::terminal<std::complex<T> >::type , my_complex<T> , boost::proto::default_domain ) }; int main() { my_complex<int> c0, c1; c0 + c1; // OK, operator+ found now! } I get this error (with gcc 4.3 and gcc 4.4): proto_complex.cpp:10: error: expected nested-name-specifier before ‘typename’ proto_complex.cpp:10: error: two or more data types in declaration of ‘proto_base_expr’ proto_complex.cpp:10: error: ‘proto_base_expr’ has not been declared proto_complex.cpp:10: error: ‘proto_base_expr’ has not been declared The strangest thing is that when I replace the macro by its explicit code the code seems to compile. Thank you, Alfredo
alfC wrote:
Is this example, contained in the boost.Proto manual supposed to compile?
#include<complex> #include <boost/proto/core.hpp> #include <boost/proto/context.hpp> #include <boost/proto/debug.hpp> #include<boost/proto/extends.hpp>
template<class T, class Dummy = boost::proto::is_proto_expr> struct my_complex { BOOST_PROTO_EXTENDS( typename boost::proto::terminal<std::complex<T> >::type , my_complex<T> , boost::proto::default_domain ) };
int main() { my_complex<int> c0, c1;
c0 + c1; // OK, operator+ found now! }
I get this error (with gcc 4.3 and gcc 4.4): proto_complex.cpp:10: error: expected nested-name-specifier before ‘typename’ proto_complex.cpp:10: error: two or more data types in declaration of ‘proto_base_expr’ proto_complex.cpp:10: error: ‘proto_base_expr’ has not been declared proto_complex.cpp:10: error: ‘proto_base_expr’ has not been declared
I seem to recall seeing this error before with gcc. I think it's a compiler bug, but I haven't investigated.
The strangest thing is that when I replace the macro by its explicit code the code seems to compile.
I think you'll find that if you replace this: BOOST_PROTO_EXTENDS( typename boost::proto::terminal<std::complex<T> >::type , my_complex<T> , boost::proto::default_domain ) with this: typedef typename boost::proto::terminal<std::complex<T> >::type terminal_type; BOOST_PROTO_EXTENDS( terminal_type , my_complex<T> , boost::proto::default_domain ) it should work. -- Eric Niebler BoostPro Computing http://www.boostpro.com
Eric Niebler wrote:
alfC wrote:
Is this example, contained in the boost.Proto manual supposed to compile?
#include<complex> #include <boost/proto/core.hpp> #include <boost/proto/context.hpp> #include <boost/proto/debug.hpp> #include<boost/proto/extends.hpp>
template<class T, class Dummy = boost::proto::is_proto_expr> struct my_complex { BOOST_PROTO_EXTENDS( typename boost::proto::terminal<std::complex<T> >::type , my_complex<T> , boost::proto::default_domain ) };
int main() { my_complex<int> c0, c1;
c0 + c1; // OK, operator+ found now! }
I get this error (with gcc 4.3 and gcc 4.4): proto_complex.cpp:10: error: expected nested-name-specifier before ‘typename’ proto_complex.cpp:10: error: two or more data types in declaration of ‘proto_base_expr’ proto_complex.cpp:10: error: ‘proto_base_expr’ has not been declared proto_complex.cpp:10: error: ‘proto_base_expr’ has not been declared
I seem to recall seeing this error before with gcc. I think it's a compiler bug, but I haven't investigated.
I take it back. This is a bug in Proto. I'll fix it. -- Eric Niebler BoostPro Computing http://www.boostpro.com
alfC wrote:
I take it back. This is a bug in Proto. I'll fix it.
Thank you,
In case you fix it. How does things work here (I am pretty new). Do you post your patch here? or the Boost svn?
It's already fixed in svn trunk. After the regression tests cycle, I will merge it to the release branch and it will be part of the next release of boost. If you'd like to see the change (it's a one-liner) you can see it here. https://svn.boost.org/trac/boost/changeset/58412 You can even get a patch file there, if you want it (see the Unified Diff) link at the bottom. HTH, -- Eric Niebler BoostPro Computing http://www.boostpro.com
It's already fixed in svn trunk. After the regression tests cycle, I will merge it to the release branch and it will be part of the next release of boost. If you'd like to see the change (it's a one-liner) you can see it here.
I saw the changes remove typedef typename Expr::proto_base_expr proto_base_expr; \ add typedef Expr proto_base_expr_; /**< INTERNAL ONLY */ \ add typedef typename proto_base_expr_::proto_base_expr proto_base_expr; \ This is more or less what I did to fix it manually. I am also glad to see this trick to get around the problem that for some macroed types 'typename' is necessary and for other it is not (I am assuming that this is the purpose). What and annoying thing this 'typename' thing! lately I am putting it everywhere just in case. It is easier to read the error message of its redundancy than the opposite one. offtopic: Do you know if this is 'typename' issue supposed to improve in the next-C++? Alfredo
participants (2)
-
alfC
-
Eric Niebler