title: boost::property_tree compile error (error C2061: syntax error : identifier 'p')
body: <p>I'm struggling to compile some code that utilises the boost property tree. I'm using Visual Studio 2010.</p>
  
  <p>If I simplify the code as much as possible to reproduce the error, the code looks like the following...</p>
  
  <pre><code>#include "AppleiTunesLibraryImporter.h"
  #include &lt;boost/property_tree/xml_parser.hpp&gt;
  #include &lt;boost/property_tree/ptree.hpp&gt;
  using namespace boost::property_tree;
  
  AppleiTunesLibraryImporter::AppleiTunesLibraryImporter(){}
  AppleiTunesLibraryImporter::~AppleiTunesLibraryImporter(){}
  
  bool AppleiTunesLibraryImporter::ImportData( std::string itunes_library_xml_path )
  {
      ptree pt;
      xml_parser::read_xml( itunes_library_xml_path.c_str(), pt, xml_parser::no_comments | xml_parser::trim_whitespace);
      return true;
  }
  </code></pre>
  
  <p>...and the full error looks like the following...</p>
  
  <pre><code>1&gt;  AppleiTunesLibraryImporter.cpp
  1&gt;c:\&lt;path to my file&gt;\thirdparty\boost\boost-1.47.0\boost/detail/allocator_utilities.hpp(178): error C2061: syntax error : identifier 'p'
  1&gt;          c:\&lt;path to my file&gt;\thirdparty\boost\boost-1.47.0\boost/multi_index/detail/index_base.hpp(88) : see reference to function template instantiation 'void boost::detail::allocator::construct&lt;T&gt;(void *,const Type &amp;)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              T=std::pair&lt;const std::string,boost::property_tree::basic_ptree&lt;std::string,std::string&gt;&gt;,
  1&gt;              Type=std::pair&lt;const std::string,boost::property_tree::basic_ptree&lt;std::string,std::string&gt;&gt;
  1&gt;          ]
  1&gt;          c:\&lt;path to my file&gt;\thirdparty\boost\boost-1.47.0\boost/multi_index/detail/index_base.hpp(87) : while compiling class template member function 'boost::multi_index::detail::index_node_base&lt;Value,Allocator&gt; *boost::multi_index::detail::index_base&lt;Value,IndexSpecifierList,Allocator&gt;::insert_(const std::pair&lt;_Ty1,_Ty2&gt; &amp;,boost::multi_index::detail::index_node_base&lt;Value,Allocator&gt; *)'
  1&gt;          with
  1&gt;          [
  1&gt;              Value=std::pair&lt;const std::string,boost::property_tree::basic_ptree&lt;std::string,std::string&gt;&gt;,
  1&gt;              Allocator=std::allocator&lt;std::pair&lt;const std::string,boost::property_tree::basic_ptree&lt;std::string,std::string&gt;&gt;&gt;,
  1&gt;              IndexSpecifierList=boost::multi_index::indexed_by&lt;boost::multi_index::sequenced&lt;&gt;,boost::multi_index::ordered_non_unique&lt;boost::multi_index::tag&lt;boost::property_tree::basic_ptree&lt;std::string,std::string&gt;::subs::by_name&gt;,boost::multi_index::member_offset&lt;std::pair&lt;const std::string,boost::property_tree::basic_ptree&lt;std::string,std::string&gt;&gt;,const std::basic_string&lt;char,std::char_traits&lt;char&gt;,std::allocator&lt;char&gt;&gt;,0&gt;,std::less&lt;std::string&gt;&gt;&gt;,
  1&gt;              _Ty1=const std::string,
  1&gt;              _Ty2=boost::property_tree::basic_ptree&lt;std::string,std::string&gt;
  1&gt;          ]
  1&gt;          c:\&lt;path to my file&gt;\thirdparty\boost\boost-1.47.0\boost/multi_index/ordered_index.hpp(119) : see reference to class template instantiation 'boost::multi_index::detail::index_base&lt;Value,IndexSpecifierList,Allocator&gt;' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              Value=std::pair&lt;const std::string,boost::property_tree::basic_ptree&lt;std::string,std::string&gt;&gt;,
  1&gt;              IndexSpecifierList=boost::multi_index::indexed_by&lt;boost::multi_index::sequenced&lt;&gt;,boost::multi_index::ordered_non_unique&lt;boost::multi_index::tag&lt;boost::property_tree::basic_ptree&lt;std::string,std::string&gt;::subs::by_name&gt;,boost::multi_index::member_offset&lt;std::pair&lt;const std::string,boost::property_tree::basic_ptree&lt;std::string,std::string&gt;&gt;,const std::basic_string&lt;char,std::char_traits&lt;char&gt;,std::allocator&lt;char&gt;&gt;,0&gt;,std::less&lt;std::string&gt;&gt;&gt;,
  1&gt;              Allocator=std::allocator&lt;std::pair&lt;const std::string,boost::property_tree::basic_ptree&lt;std::string,std::string&gt;&gt;&gt;
  1&gt;          ]
  1&gt;          c:\&lt;path to my file&gt;\thirdparty\boost\boost-1.47.0\boost/multi_index/sequenced_index.hpp(77) : see reference to class template instantiation 'boost::multi_index::detail::ordered_index&lt;KeyFromValue,Compare,SuperMeta,TagList,Category&gt;' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              KeyFromValue=boost::multi_index::member_offset&lt;std::pair&lt;const std::string,boost::property_tree::basic_ptree&lt;std::string,std::string&gt;&gt;,const std::basic_string&lt;char,std::char_traits&lt;char&gt;,std::allocator&lt;char&gt;&gt;,0&gt;,
  1&gt;              Compare=std::less&lt;std::string&gt;,
  1&gt;              SuperMeta=boost::multi_index::detail::nth_layer&lt;2,std::pair&lt;const std::string,boost::property_tree::basic_ptree&lt;std::string,std::string&gt;&gt;,boost::multi_index::indexed_by&lt;boost::multi_index::sequenced&lt;&gt;,boost::multi_index::ordered_non_unique&lt;boost::multi_index::tag&lt;boost::property_tree::basic_ptree&lt;std::string,std::string&gt;::subs::by_name&gt;,boost::multi_index::member_offset&lt;std::pair&lt;const std::string,boost::property_tree::basic_ptree&lt;std::string,std::string&gt;&gt;,const std::basic_string&lt;char,std::char_traits&lt;char&gt;,std::allocator&lt;char&gt;&gt;,0&gt;,std::less&lt;std::string&gt;&gt;&gt;,std::allocator&lt;std::pair&lt;const std::string,boost::property_tree::basic_ptree&lt;std::string,std::string&gt;&gt;&gt;&gt;,
  1&gt;              TagList=boost::mpl::vector1&lt;boost::property_tree::basic_ptree&lt;std::string,std::string&gt;::subs::by_name&gt;,
  1&gt;              Category=boost::multi_index::detail::ordered_non_unique_tag
  1&gt;          ]
  1&gt;          c:\&lt;path to my file&gt;\thirdparty\boost\boost-1.47.0\boost/multi_index_container.hpp(89) : see reference to class template instantiation 'boost::multi_index::detail::sequenced_index&lt;SuperMeta,TagList&gt;' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              SuperMeta=boost::multi_index::detail::nth_layer&lt;1,std::pair&lt;const std::string,boost::property_tree::basic_ptree&lt;std::string,std::string&gt;&gt;,boost::multi_index::indexed_by&lt;boost::multi_index::sequenced&lt;&gt;,boost::multi_index::ordered_non_unique&lt;boost::multi_index::tag&lt;boost::property_tree::basic_ptree&lt;std::string,std::string&gt;::subs::by_name&gt;,boost::multi_index::member_offset&lt;std::pair&lt;const std::string,boost::property_tree::basic_ptree&lt;std::string,std::string&gt;&gt;,const std::basic_string&lt;char,std::char_traits&lt;char&gt;,std::allocator&lt;char&gt;&gt;,0&gt;,std::less&lt;std::string&gt;&gt;&gt;,std::allocator&lt;std::pair&lt;const std::string,boost::property_tree::basic_ptree&lt;std::string,std::string&gt;&gt;&gt;&gt;,
  1&gt;              TagList=boost::mpl::vector0&lt;boost::mpl::na&gt;
  1&gt;          ]
  1&gt;          c:\&lt;path to my file&gt;\thirdparty\boost\boost-1.47.0\boost/property_tree/detail/ptree_implementation.hpp(59) : see reference to class template instantiation 'boost::multi_index::multi_index_container&lt;Value,IndexSpecifierList&gt;' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              Value=std::pair&lt;const std::string,boost::property_tree::basic_ptree&lt;std::string,std::string&gt;&gt;,
  1&gt;              IndexSpecifierList=boost::multi_index::indexed_by&lt;boost::multi_index::sequenced&lt;&gt;,boost::multi_index::ordered_non_unique&lt;boost::multi_index::tag&lt;boost::property_tree::basic_ptree&lt;std::string,std::string&gt;::subs::by_name&gt;,boost::multi_index::member_offset&lt;std::pair&lt;const std::string,boost::property_tree::basic_ptree&lt;std::string,std::string&gt;&gt;,const std::basic_string&lt;char,std::char_traits&lt;char&gt;,std::allocator&lt;char&gt;&gt;,0&gt;,std::less&lt;std::string&gt;&gt;&gt;
  1&gt;          ]
  1&gt;          c:\&lt;path to my file&gt;\thirdparty\boost\boost-1.47.0\boost/property_tree/detail/ptree_implementation.hpp(182) : see reference to class template instantiation 'boost::property_tree::basic_ptree&lt;Key,Data&gt;::subs' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              Key=std::string,
  1&gt;              Data=std::string
  1&gt;          ]
  1&gt;          c:\&lt;path to my file&gt;\thirdparty\boost\boost-1.47.0\boost/property_tree/detail/ptree_implementation.hpp(182) : while compiling class template member function 'boost::property_tree::basic_ptree&lt;Key,Data&gt;::basic_ptree(void)'
  1&gt;          with
  1&gt;          [
  1&gt;              Key=std::string,
  1&gt;              Data=std::string
  1&gt;          ]
  1&gt;          ..\..\..\common\Source\AppleiTunesImporter\AppleiTunesLibraryImporter.cpp(24) : see reference to class template instantiation 'boost::property_tree::basic_ptree&lt;Key,Data&gt;' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              Key=std::string,
  1&gt;              Data=std::string
  1&gt;          ]
  </code></pre>
  
  <p>For me, line 24 of my ApplieiTunesLibraryImporter.cpp file is just</p>
  
  <pre><code>ptree pt;
  </code></pre>
  
  <p>so, the compiler is not liking my use of it. I can get similar errors when I use something like</p>
  
  <pre><code>ptree::const_assoc_iterator assoc_iter;
  </code></pre>
  
  <p>but the above code is the simplest I can make the error happen.</p>
  
  <p>The code inside the boost file (allocator_utilities.hpp) that is causing the compilation error looks like the following, but it's quite cryptic to me.</p>
  
  <pre><code>/* allocator-independent versions of construct and destroy */
  
  template&lt;typename Type&gt;
  void construct(void* p,const Type&amp; t)
  {
    new (p) Type(t);
  }
  </code></pre>
  
  <p>In case someone wants to try and reproduce, here is the .h code.</p>
  
  <pre><code>class AppleiTunesLibraryImporter
  {
  public:
  
      AppleiTunesLibraryImporter();
      virtual ~AppleiTunesLibraryImporter();
  
      bool ImportData( std::string itunes_library_xml_path );
  
  };
  </code></pre>
  
  <p>This has all turned into a bit of brain melt so if anyone can shed some light on this, it would be greatly appreciated.</p>
  
  <p>Cheers.</p>