我不能编译yaml-cpp
在RAD Studio 2010中我在nodeutil.h
错误YAML-CPP中的RAD Studio编译2010
template <typename T, typename U>
struct is_same_type {
enum { value = false };
};
template <typename T>
struct is_same_type<T, T> {
enum { value = true };
};
template <typename T, bool check>
struct is_index_type_with_check {
enum { value = false };
};
template <> struct is_index_type_with_check<std::size_t, false>
{ enum { value = true }; }; // line 24
#define MAKE_INDEX_TYPE(Type) \
template <> struct is_index_type_with_check<Type, is_same_type<Type, std::size_t>::value> { enum { value = true }; }
MAKE_INDEX_TYPE(int);
MAKE_INDEX_TYPE(unsigned); // line 30
MAKE_INDEX_TYPE(short);
MAKE_INDEX_TYPE(unsigned short);
MAKE_INDEX_TYPE(long);
MAKE_INDEX_TYPE(unsigned long);
#undef MAKE_INDEX_TYPE
编译器打印有错误:
[BCC32 Error] nodeutil.h(30): E2238 Multiple declaration for 'is_index_type_with_check<unsigned int,0>'
[BCC32 Error] nodeutil.h(24): E2344 Earlier declaration of 'is_index_type_with_check<unsigned int,0>'
我认为所有正确的 - 在24行我得到
is_index_type_with_check<std::size_t, false>
,
在第30行我
is_index_type_with_check<unsigned, true>
。
两种不同类型。
但是,如果我改变线24象下面,RAD Studio可以编译yaml-cpp
template <> struct is_index_type_with_check<std::size_t, true> { enum { value = true }; }; // false -> true
为什么?在第24行我
is_index_type_with_check<std::size_t, true>
和线30
is_index_type_with_check<unsigned, true>
两个相同类型。但所有工作在RAD Studio中,并不在MS VS 2008 Express中。
你想在你的问题的最后一个块中写'std :: size_t,true'? – 2010-03-05 13:55:06
我写这个。但我不明白2件事 - 为什么第一选择是错误的,为什么第二选择工作。我认为SFINAE,但在我的系统'std :: size_t'等于'unsigned int'。 – Xeningem 2010-03-05 22:57:45