title: Compiler error coming out of yaml-cpp
body: <p>I'm attempting to integrate yaml-cpp into a project, but I'm seeing some unexpected errors out of GCC.  For example:</p>
  
  <pre><code>g++ -c -ggdb3 -ansi -Wall -Werror -pedantic-errors src/commands-tz.cpp -o obj/commands-tz.o
  In file included from /usr/local/include/yaml-cpp/conversion.h:9,
                   from /usr/local/include/yaml-cpp/node.h:8,
                   from /usr/local/include/yaml-cpp/parser.h:8,
                   from /usr/local/include/yaml-cpp/yaml.h:8,
                   from src/note.h:26,
                   from src/commands-tz.cpp:297:
  /usr/local/include/yaml-cpp/traits.h:26: error: expected identifier before ‘(’ token
  /usr/local/include/yaml-cpp/traits.h:26: error: expected ‘)’ before numeric constant
  /usr/local/include/yaml-cpp/traits.h:26: error: expected ‘&gt;’ before numeric constant
  /usr/local/include/yaml-cpp/traits.h:26: error: expected unqualified-id before ‘)’ token
  /usr/local/include/yaml-cpp/traits.h:31: error: expected identifier before ‘(’ token
  /usr/local/include/yaml-cpp/traits.h:31: error: expected ‘)’ before numeric constant
  /usr/local/include/yaml-cpp/traits.h:31: error: expected ‘&gt;’ before numeric constant
  /usr/local/include/yaml-cpp/traits.h:31: error: expected unqualified-id before ‘)’ token
  /usr/local/include/yaml-cpp/traits.h:34: error: expected identifier before ‘(’ token
  /usr/local/include/yaml-cpp/traits.h:34: error: expected ‘)’ before numeric constant
  /usr/local/include/yaml-cpp/traits.h:34: error: expected ‘&gt;’ before numeric constant
  /usr/local/include/yaml-cpp/traits.h:34: error: expected unqualified-id before ‘)’ token
  /usr/local/include/yaml-cpp/traits.h:37: error: expected identifier before ‘(’ token
  /usr/local/include/yaml-cpp/traits.h:37: error: expected ‘)’ before numeric constant
  /usr/local/include/yaml-cpp/traits.h:37: error: expected ‘&gt;’ before numeric constant
  /usr/local/include/yaml-cpp/traits.h:37: error: expected unqualified-id before ‘)’ token
  /usr/local/include/yaml-cpp/traits.h:42: error: expected identifier before ‘(’ token
  /usr/local/include/yaml-cpp/traits.h:42: error: expected ‘)’ before numeric constant
  /usr/local/include/yaml-cpp/traits.h:42: error: expected ‘&gt;’ before numeric constant
  /usr/local/include/yaml-cpp/traits.h:42: error: expected unqualified-id before ‘)’ token
  /usr/local/include/yaml-cpp/traits.h:45: error: expected identifier before ‘(’ token
  /usr/local/include/yaml-cpp/traits.h:45: error: expected ‘)’ before numeric constant
  /usr/local/include/yaml-cpp/traits.h:45: error: expected ‘&gt;’ before numeric constant
  /usr/local/include/yaml-cpp/traits.h:45: error: expected unqualified-id before ‘)’ token
  </code></pre>
  
  <p>Another example:</p>
  
  <pre><code>In file included from /usr/local/include/yaml-cpp/nodeimpl.h:8,
                   from /usr/local/include/yaml-cpp/node.h:139,
                   from /usr/local/include/yaml-cpp/parser.h:8,
                   from /usr/local/include/yaml-cpp/yaml.h:8,
                   from src/note.h:26,
                   from src/commands-tz.cpp:297:
  /usr/local/include/yaml-cpp/nodeutil.h:9: error: expected nested-name-specifier before ‘(’ token
  /usr/local/include/yaml-cpp/nodeutil.h:9: error: expected ‘)’ before numeric constant
  /usr/local/include/yaml-cpp/nodeutil.h:9: error: expected ‘&gt;’ before numeric constant
  /usr/local/include/yaml-cpp/nodeutil.h:9: error: expected unqualified-id before ‘)’ token
  /usr/local/include/yaml-cpp/nodeutil.h:14: error: expected nested-name-specifier before ‘(’ token
  /usr/local/include/yaml-cpp/nodeutil.h:14: error: expected ‘)’ before numeric constant
  /usr/local/include/yaml-cpp/nodeutil.h:14: error: expected ‘&gt;’ before numeric constant
  /usr/local/include/yaml-cpp/nodeutil.h:14: error: expected unqualified-id before ‘)’ token
  /usr/local/include/yaml-cpp/nodeutil.h:19: error: expected nested-name-specifier before ‘(’ token
  /usr/local/include/yaml-cpp/nodeutil.h:19: error: expected ‘)’ before numeric constant
  /usr/local/include/yaml-cpp/nodeutil.h:19: error: expected ‘&gt;’ before numeric constant
  /usr/local/include/yaml-cpp/nodeutil.h:19: error: expected unqualified-id before ‘)’ token
  /usr/local/include/yaml-cpp/nodeutil.h:24: error: ‘is_index_type_with_check’ is not a template
  /usr/local/include/yaml-cpp/nodeutil.h:24: error: explicit specialization of non-template ‘YAML::is_index_type_with_check’
  </code></pre>
  
  <p>My platform is Fedora (2.6.32 kernel), GCC 4.4.1, and yaml-cpp 0.2.5. There are many, many other errors. To the naked eye, this seems like a problem within yaml-cpp, but experience tells me I'm probably the one at fault.  Any ideas?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The file traits.h contains the following:</p>
  
  <pre><code>namespace YAML
  {
          template &lt;typename&gt;
          struct is_numeric { enum { value = false }; };
  
          template &lt;&gt; struct is_numeric &lt;char&gt; { enum { value = true }; };
          template &lt;&gt; struct is_numeric &lt;unsigned char&gt; { enum { value = true }; };
          template &lt;&gt; struct is_numeric &lt;int&gt; { enum { value = true }; };
          template &lt;&gt; struct is_numeric &lt;unsigned int&gt; { enum { value = true }; };
          template &lt;&gt; struct is_numeric &lt;long int&gt; { enum { value = true }; };
          template &lt;&gt; struct is_numeric &lt;unsigned long int&gt; { enum { value = true }; };
          template &lt;&gt; struct is_numeric &lt;short int&gt; { enum { value = true }; };
          template &lt;&gt; struct is_numeric &lt;unsigned short int&gt; { enum { value = true }; };
          template &lt;&gt; struct is_numeric &lt;long long&gt; { enum { value = true }; };
          template &lt;&gt; struct is_numeric &lt;unsigned long long&gt; { enum { value = true }; };
          template &lt;&gt; struct is_numeric &lt;float&gt; { enum { value = true }; };
          template &lt;&gt; struct is_numeric &lt;double&gt; { enum { value = true }; };
          template &lt;&gt; struct is_numeric &lt;long double&gt; { enum { value = true }; };
  
          template &lt;bool, class T = void&gt;
          struct enable_if_c {
            typedef T type;
          };
  
          template &lt;class T&gt;
          struct enable_if_c&lt;false, T&gt; {};
  
          template &lt;class Cond, class T = void&gt;
          struct enable_if : public enable_if_c&lt;Cond::value, T&gt; {};
  
          template &lt;bool, class T = void&gt;
          struct disable_if_c {
            typedef T type;
          };
  
          template &lt;class T&gt;
          struct disable_if_c&lt;true, T&gt; {};
  
          template &lt;class Cond, class T = void&gt;
          struct disable_if : public disable_if_c&lt;Cond::value, T&gt; {};
  }
  </code></pre>
  
  <p>And nodeutil.h contains:</p>
  
  <pre><code>namespace YAML
  {
          template &lt;typename T, typename U&gt;
          struct is_same_type {
                  enum { value = false };
          };
  
          template &lt;typename T&gt;
          struct is_same_type&lt;T, T&gt; {
                  enum { value = true };
          };
  
          template &lt;typename T, bool check&gt;
          struct is_index_type_with_check {
                  enum { value = false };
          };
  
          template &lt;&gt; struct is_index_type_with_check&lt;std::size_t, false&gt; { enum { value = true }; };
  
  #define MAKE_INDEX_TYPE(Type) \
          template &lt;&gt; struct is_index_type_with_check&lt;Type, is_same_type&lt;Type, std::size_t&gt;::value&gt; { enum { value = true }; }
  
          MAKE_INDEX_TYPE(int);
          MAKE_INDEX_TYPE(unsigned);
          MAKE_INDEX_TYPE(short);
          MAKE_INDEX_TYPE(unsigned short);
          MAKE_INDEX_TYPE(long);
          MAKE_INDEX_TYPE(unsigned long);
  
  #undef MAKE_INDEX_TYPE
  
          template &lt;typename T&gt;
          struct is_index_type: public is_index_type_with_check&lt;T, false&gt; {};
  
          // messing around with template stuff to get the right overload for operator [] for a sequence
          template &lt;typename T, bool b&gt;
          struct _FindFromNodeAtIndex {
                  const Node *pRet;
                  _FindFromNodeAtIndex(const Node&amp;, const T&amp;): pRet(0) {}
          };
  
          template &lt;typename T&gt;
          struct _FindFromNodeAtIndex&lt;T, true&gt; {
                  const Node *pRet;
                  _FindFromNodeAtIndex(const Node&amp; node, const T&amp; key): pRet(node.FindAtIndex(static_cast&lt;std::size_t&gt;(key))) {}
          };
  
          template &lt;typename T&gt;
          inline const Node *FindFromNodeAtIndex(const Node&amp; node, const T&amp; key) {
                  return _FindFromNodeAtIndex&lt;T, is_index_type&lt;T&gt;::value&gt;(node, key).pRet;
          }
  }
  </code></pre>