Я пытаюсь преобразовать код C ++ 11 в C ++ 03 и застрял в аргументе шаблона по умолчанию.
#include <type_traits>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/conditional.hpp>
#include <boost/spirit/home/support/string_traits.hpp>
template<bool B, class T = void>
struct enable_if {};
template<class T>
struct enable_if<true, T> { typedef T type; };
template<typename T>
struct is_char
{
typedef typename enable_if<sizeof (T) == sizeof (char)>::type eif;
};
template<bool B, class T, class F>
struct conditional { typedef T type; };
template<class T, class F>
struct conditional<false, T, F> { typedef F type; };
template <typename ObjType,
typename PtrType,
typename CharType =
typename conditional<boost::is_const<PtrType>::value,
const typename ObjType::char_type,
typename ObjType::char_type>::type,
typename is_char<PtrType>::type >
CharType* char_ptr_cast(PtrType* p)
{ return reinterpret_cast<CharType*>(p); }
int main ()
{}
Я получаю следующую ошибку:
> /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/c++0x_warning.h:31:2:
> error: #error This file requires compiler and library support for the
> upcoming ISO C++ standard, C++0x. This support is currently
> experimental, and must be enabled with the -std=c++0x or -std=gnu++0x
> compiler options.
>
> test.cc:35: error: no default argument for anonymous
>
> **default template arguments may not be used in function templates without -std=c++0x or -std=gnu++0x**
Не могли бы вы помочь мне решить эти ошибки?