Is initializing with “var{args}” a new feature of C++0x, or merely syntactic sugar?

后端 未结 3 1004
再見小時候
再見小時候 2021-01-20 05:18

I was reading the C++0x faq and came across the section detailing initializer lists. The examples were mostly variations of:

vector vi = { 1, 2,          


        
3条回答
  •  盖世英雄少女心
    2021-01-20 05:52

    One is uniform initialization, and the other is initializer lists. They are two different things, although as you can see, they can produce similar syntax.

    vector vk{2};
    

    is a uniform initialization- the other two are initializer lists.

提交回复
热议问题