Request Short Link
C++ 98
C++ 11
C++ 14
C++ 17
C++ 20
C++ 23
C++ 2c
for-loops as while-loops
array subscription
Show all implicit casts
Show all template parameters of a CallExpr
Use libc++
Transform std::initializer_list
Show noexcept internals
Show padding information
Show coroutine transformation
Show C++ to C transformation
Show object lifetime
Default
15
18
20
22
26
More
GitHub
Patreon
Issues
About
Policies
Examples
C++ Insights @ YouTube
Settings
Version
New C++ Insights Episode
×
Made by
Andreas Fertig
Powered by
Flask
and
CodeMirror
Source:
#include <bits/stdc++.h> using namespace std; void f() {} int main() { auto i2 = {0}; // (2) i2 类型推导为 std::initializer_list<int> auto i3 {0}; // (3) i3 类型推导为 int auto m2 = {0,1}; // (2) m2 类型推导为 std::initializer_list<int> // auto m3 {0,1}; // (3) error: initializer for variable 'm3' with type 'auto' contains multiple expressions std::string s1="hello"; // (1) 拷贝初始化,C++14 和 C++17 有细微差别 std::string s2={"hello"}; // (2) 拷贝初始化 std::string s3{"hello"}; // (3) 直接初始化 std::string s4("hello"); // (4) 直接初始化 atomic<int> a1=0; // (1) C++14 报错:拷贝构造被删除;C++17 可以编译 atomic<int> a2={0}; // (2) atomic<int> a3{0}; // (3) atomic<int> a4(0); // (4) // thread t1=f; // thread t2={f}; // error: chosen constructor is explicit in copy-initialization thread t3{f}; thread t4(f); }
Insight:
Console: