
On 02/03/11 17:02, Steven Watanabe wrote:
AMDG
On 2/3/2011 2:42 PM, Edward Diener wrote:
Compiling this code with gcc:
#include <boost/config.hpp> #include <boost/mpl/apply.hpp>
template < class MF, class T
struct myMF : boost::mpl::apply<MF,T> { BOOST_STATIC_CONSTANT(bool,value=type::value); };
int main() { return 0; }
Gives:
"gcc.compile.c++ ..\..\..\bin.v2\libs\tti\test\TestMFHasTypeMFC.test\gcc-mingw-4.5.2\debug\TestMFHasTypeMFC.o
TestMFHasTypeMFC.cpp:18:5: error: 'type' has not been declared
gcc is correct. Members of a dependent base class are not visible in the derived class. (This is necessary to allow the template to be parsed before the template arguments are known.).
Add using typename boost::mpl::apply<MF,T>::type;
In Christ, Steven Watanabe _______________________________________________ That using works with clang++; however, my gcc (gcc4.5.1) still doesn't like it:
make using cat myMF.cpp //Copied from post with headers: /* From: Edward Diener <eldiener@tropicsoft.com> Newsgroups: gmane.comp.lib.boost.devel Subject: [mpl] Using apply with gcc error Date: Thu, 03 Feb 2011 17:42:44 -0500 Lines: 47 */ #include <boost/config.hpp> #include <boost/mpl/apply.hpp> template < class MF, class T > struct myMF : boost::mpl::apply<MF,T> { using typename boost::mpl::apply<MF,T>::type; BOOST_STATIC_CONSTANT(bool,value=type::value); }; int main() { return 0; } /home/evansl/download/llvm/svn/build/Debug+Asserts/bin/clang++ -c -std=c++0x -U__GXX_EXPERIMENTAL_CXX0X__ -c myMF.cpp /home/evansl/download/gcc/4.5.1-release/install/bin/g++ -c -Wall -ftemplate-depth-300 -O0 -std=gnu++0x -c myMF.cpp myMF.cpp:21:6: error: 'type' is not a class, namespace, or enumeration make: [using] Error 1 (ignored) Compilation finished at Thu Feb 3 17:04:44