1 #ifndef NODEUTIL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
2 #define NODEUTIL_H_62B23520_7C8E_11DE_8A39_0800200C9A66
4 #if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4
11 template <typename T
, typename U
>
13 enum { value
= false };
17 struct is_same_type
<T
, T
> {
18 enum { value
= true };
21 template <typename T
, bool check
>
22 struct is_index_type_with_check
{
23 enum { value
= false };
26 template <> struct is_index_type_with_check
<std::size_t, false> { enum { value
= true }; };
28 #define MAKE_INDEX_TYPE(Type) \
29 template <> struct is_index_type_with_check<Type, is_same_type<Type, std::size_t>::value> { enum { value = true }; }
32 MAKE_INDEX_TYPE(unsigned);
33 MAKE_INDEX_TYPE(short);
34 MAKE_INDEX_TYPE(unsigned short);
35 MAKE_INDEX_TYPE(long);
36 MAKE_INDEX_TYPE(unsigned long);
38 #undef MAKE_INDEX_TYPE
41 struct is_index_type
: public is_index_type_with_check
<T
, false> {};
43 // messing around with template stuff to get the right overload for operator [] for a sequence
44 template <typename T
, bool b
>
45 struct _FindFromNodeAtIndex
{
47 _FindFromNodeAtIndex(const Node
&, const T
&): pRet(0) {}
51 struct _FindFromNodeAtIndex
<T
, true> {
53 _FindFromNodeAtIndex(const Node
& node
, const T
& key
): pRet(node
.FindAtIndex(static_cast<std::size_t>(key
))) {}
57 inline const Node
*FindFromNodeAtIndex(const Node
& node
, const T
& key
) {
58 return _FindFromNodeAtIndex
<T
, is_index_type
<T
>::value
>(node
, key
).pRet
;
62 #endif // NODEUTIL_H_62B23520_7C8E_11DE_8A39_0800200C9A66