Boost::typeof compiler problem: mangling typeof, use decltype instead
short example:
#include <boost/typeof/typeof.hpp>
#include <boost/proto/core.hpp>
using namespace boost;
template<class T, class U>
BOOST_TYPEOF_TPL(T() + U()) add2(const T& t, const U& u)
{
return t + u;
};
int main(){
typedef BOOST_TYPEOF(add2(2.5, 1.5)) type; // get type -> works
BOOST_STATIC_ASSERT((is_same<type, double>::value)); // check if double -> no error -> double
double xxx = add2(1.5,1.5); // cause the problems
return 0;
}
When i try to compile this i become a error like:
g++-4.3: sorry, unimplemented: mangling typeof, use decltype instead
g++-4.2: internal compiler error: in write_type, at cp/mangle.c:1648
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
For Debian GNU/Linux specific bug reporting instructions,
see <URL:file:///usr/share/doc/gcc-4.2/README.Bugs>.
gcc version 4.3.2 (Debian 4.3.2-1.1) gcc version 4.2.4 (Debian 4.2.4-6)
Where is the Prob开发者_开发问答lem or what i do wrong?a
The example in the typeof documentation first wraps the result of the BOOST_TYPEOF_TPL macro in a templated struct, then uses that when declaring the function. Does that work any better for you?
template<class T, class U>
struct result_of_add2
{
typedef BOOST_TYPEOF_TPL(T() + U()) type;
};
template<class T, class U>
typename result_of_add2<T, U>::type add2(const T& t, const U& u)
{
return t + u;
};
精彩评论