Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
MSVCStatic
#include <iostream> // 1 static int initBeforeMain = [] { std::cout << "1 initBeforeMain" << std::endl; return 10; }(); // 2 struct Base { static int initInBase; }; int Base::initInBase = [] { std::cout << "2 initInBase" << std::endl; return 10; }(); struct Derived : Base {}; // 3 template<typename T, T> struct StaticInitializer { }; template<class T> struct BaseT { static int initInBase; using initStatic = StaticInitializer<int&, initInBase>; }; template<class T> int BaseT<T>::initInBase = [] { std::cout << "3 initInBase template" << std::endl; return 10; }(); struct DerivedT : BaseT<int> {}; // 4 template<typename T, T> struct BitFieldSize { constexpr static int value = 0; }; using CharT = char; template<typename T> struct BaseWithoutNewTypes { static int initInBase; CharT :BitFieldSize<int&, initInBase>::value; }; template<class T> int BaseWithoutNewTypes<T>::initInBase = [] { std::cout << "4 initInBase template without new types" << std::endl; return 10; }(); struct DerivedWithoutTypes : BaseWithoutNewTypes<int> {}; // 5 MSVC specific template<typename T> struct BaseForMSVC { static int initInBase; constexpr static int *unusedAddr = &initInBase; }; template<class T> int BaseForMSVC<T>::initInBase = [] { std::cout << "5 initInBase MSVC" << std::endl; return 10; }(); struct DerivedMSVC : BaseForMSVC<int> {}; int main () { // 2 Derived d; // 3 DerivedT dt; // 4 DerivedWithoutTypes dwt; // 5 DerivedMSVC dmsvc; }
run
|
edit
|
history
|
help
0
map_file_mangling
Redeclare with auto
😊
fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
ccloader
MSVC14 <exception> header
VC++
VC++ '-flag Fail
Memory example
Wide string conversion with multibyte chars