Take a look at this code:
struct Foo { void *ptr; constexpr Foo() : ptr(nullptr) { } }; Foo f;
Is it guaranteed to fbe statically initialized?
f
Clang uses static initialization here, but MSVC does not .
Yes, the Standard says it fwill initialize by default:
[basic.start.init] / 2:
o , , , constexpr o , [ : - ]. :... [ ], ,... [ , ], - ; - . .
o , , , constexpr o , [ : - ]. :
o
constexpr
... [ ]
, ,
... [ , ]
, - ; - . .
- Foo, .
Foo
MSVC f.
, . - .
, .
[edit] Clang - - .
I believe this will also be in msvc (at least against 2015) if you have to declare f itself as constexpr Foo f;
Source: https://habr.com/ru/post/1686265/More articles:Merge objects with an array and save both array values - javascriptDocker for Mac - mkmf.rb cannot find header files for ruby - ruby | fooobar.comAzure Logic apps cannot connect - azureFlutter - определяет положение прокрутки ListView, вверху или внизу? - dartHow to use the "segments" mode in SourceBuffer MediaSource to make the same result in Chomium, Chorme and Firefox? - javascriptSetting a constant fixed width for a parent div element does not work - jqueryAccording to him, I have no choice? - sqllibgcov fork и exec hooks - cЯвляется ли антисоединение более эффективным, чем левое внешнее соединение? - oracleChoosing nth-child for a potentially endless list of children - mathAll Articles