小编Ray*_*des的帖子

什么时候需要使用标志-stdlib = libstdc ++?

什么时候需要使用-stdlib=libstdc++gcc编译时使用编译器和链接器的标志?

编译器是否自动使用libstdc ++?

我在Ubuntu 13.10上使用gcc4.8.2,我想使用c ++ 11标准.我已经传递-std=c++11给了编译器.

c++ gcc std libstdc++ c++11

48
推荐指数
3
解决办法
7万
查看次数

如何从boost :: property_tree获取枚举?

如何从中获取枚举boost::property_tree

这是我的"不工作"的例子.

config.xml中

<root>
  <fooEnum>EMISSION::EMIT1</fooEnum>
  <fooDouble>42</fooDouble>
</root>
Run Code Online (Sandbox Code Playgroud)

main.cpp中

#include <iostream>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>

int main()
{
  enum class EMISSION { EMIT1, EMIT2 } ;
  enum EMISSION myEmission;

  //Initialize the XML file into property_tree
  boost::property_tree::ptree pt;
  read_xml("config.xml", pt);

  //test enum (SUCCESS)
  myEmission = EMISSION::EMIT1;
  std::cout << (myEmission == EMISSION::EMIT1) << "\n";

  //test basic ptree interpreting capability (SUCCESS)
  const double fooDouble = pt.get<double>("root.fooDouble");
  std::cout << fooDouble << "\n";

  //read from enum from ptree and assign (FAILURE)
  myEmission = pt.get<enum …
Run Code Online (Sandbox Code Playgroud)

c++ boost-propertytree xml-parsing c++11 enum-class

4
推荐指数
1
解决办法
1590
查看次数

为什么模板类有未使用的类型?

我正在审查boost单元库,我很困惑为什么boost :: units :: unit类有一个额外的模板参数.这是一个例子:

http://www.boost.org/doc/libs/1_57_0/boost/units/unit.hpp

template<class Dim,class System, class Enable>
class unit
{
    public:
        typedef unit<Dim, System>   unit_type;
        typedef unit<Dim,System>    this_type;
        typedef Dim                 dimension_type; 
        typedef System              system_type;

        unit() { }
        unit(const this_type&) { }
        //~unit() { }  

        this_type& operator=(const this_type&) { return *this; }

        // sun will ignore errors resulting from templates
        // instantiated in the return type of a function.
        // Make sure that we get an error anyway by putting.
        // the check in the destructor.
        #ifdef …
Run Code Online (Sandbox Code Playgroud)

c++ templates generic-programming boost-units template-classes

4
推荐指数
1
解决办法
355
查看次数