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
None
×
Made by
Andreas Fertig
Powered by
Flask
and
CodeMirror
Source:
#include <bits/stdc++.h> using namespace std; void f() {} int main() { int a[10]; decltype(a) b; // b 的类型为 int[10] auto c{a}; // c 的类型为 int* auto& d{a}; // d 的类型为 int(&)[10] initializer_list<double> il {3.0,4}; auto aa{3}; auto aaa = {3}; //auto a3 {}; 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: