common: win32utils - compile fix
[supercollider.git] / external_libraries / yaml-cpp-0.2.6 / include / yaml-cpp / nodeutil.h
blob98ea4fa08a71682819001d4a31a7073989630c6c
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
5 #pragma once
6 #endif
9 namespace YAML
11 template <typename T, typename U>
12 struct is_same_type {
13 enum { value = false };
16 template <typename T>
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 }; }
31 MAKE_INDEX_TYPE(int);
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
40 template <typename T>
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 {
46 const Node *pRet;
47 _FindFromNodeAtIndex(const Node&, const T&): pRet(0) {}
50 template <typename T>
51 struct _FindFromNodeAtIndex<T, true> {
52 const Node *pRet;
53 _FindFromNodeAtIndex(const Node& node, const T& key): pRet(node.FindAtIndex(static_cast<std::size_t>(key))) {}
56 template <typename T>
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