【问题标题】:initializer_list in visual studio 2012Visual Studio 2012 中的 initializer_list
【发布时间】:2012-10-07 09:25:56
【问题描述】:

我发现 MSVC 2012 不支持 initializer_list。但是可以吗 (initializer_list) 以某种方式在 VS 中使用(例如在 Boost 库的帮助下)。如果可以,请提供样品。

【问题讨论】:

    标签: c++ visual-c++ c++11 visual-studio-2012 initializer


    【解决方案1】:

    Boost::assign 与您一样接近。

    更具体地说,assign::list_of 可能与您正在寻找的行为相似。

    // Examples from the documentation:
    const list<int> primes = list_of(2)(3)(5)(7)(11);
    const stack<string> names = list_of( "Mr. Foo" )( "Mr. Bar")( "Mrs. FooBar" ).to_adapter();
    map<int,int> next = map_list_of(1,2)(2,3)(3,4)(4,5)(5,6);
    

    【讨论】:

      猜你喜欢
      • 2016-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多