Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
MSVCStatic
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#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; }
cl.exe
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 1,81 sec, absolute running time: 0,33 sec, absolute service time: 2,15 sec
edit mode
|
history
|
discussion
1 initBeforeMain 2 initInBase 5 initInBase MSVC