Error: ‘is_same’ is not a member of ‘std’ when build c++ project in ubuntu?

I have a small project and i get an error ‘is_same’ is not a member of ‘std’ when building. this is some code:

template <class T>
T* UcmExportFactory::Unwrap (T* ptr)
{ Utils::IUcmWrapper* wrapper = dynamic_cast<Utils::IUcmWrapper*> (ptr); // If the requested Ucm inteface is derived from an another (such as IUcmV from IUcmUnionValue), specify that whether we want the base class pointer or not. bool interfaceForAbstractBase = (std::is_same<IUcmUnionValue, T>::value || std::is_same<IUcmDiagCodedType, T>::value); return (wrapper) ? boost::any_cast<T*> ( wrapper->GetWrappedObject (interfaceForAbstractBase) ) : ptr;
}

Anyone can help me. I included header #include <type_traits>. Thanks.

2 Answers

std::is_same is a C++11 feature. Ubuntu 12.04 has GCC 4.6.3, which has only incomplete C++0x (not yet C++11) support. You can try by specifying the standard:

g++ --std=c++0x ...
0

Just a reminder to anyone landing on this page, as the OP has stated he did this:

You'll also get this error if you do not include the type_traits header, so don't forget that:

#include <type_traits>

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like