Request Short Link
C++ 98
C++ 11
C++ 14
C++ 17
C++ 20
C++ 2b
for-loops as while-loops
array subscription
Show all implicit casts
Use libc++
std::initializer_list
Show noexcept internals
Show padding information
Show coroutine transformation
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 <iostream> #include <vector> // class template with type parameter template <class T> class Container { public: Container(T val): val_(val) {} private: T val_; }; // function template with non-type parameter // also has default value template <int T = 1> void foo() { std::cout << T; } // function template with type paramater pack // this also uses fold expression(C++17 onwards) template <class... Args> bool logical_and(Args... args) { return (... && args); } // concept (C++20 onwards) template <class T> concept IntSized = (sizeof(int) == sizeof(T)); // and with this concept you can constrain parameter of other template template <IntSized T> T sum(T a, T b) { return a + b; } // or like this template <class T> requires IntSized<T> T sum(T a, T b) { return a + b; } template<class T> struct Alloc { }; // alias template template<class T> using Vec = std::vector<T, Alloc<T>>; int main() { return 0; }
Insight:
Console: