4

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

4

1 回答 1

6

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);
于 2012-10-17T07:11:19.887 回答