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
Workshop: Safe and Efficient C++ for Embedded Environments
×
Made by
Andreas Fertig
Powered by
Flask
and
CodeMirror
Source:
#include <iostream> #include <memory> class C { public: C() { std::cout << "C()\n"; } C(const C& c) { std::cout << "C(const C&)\n"; } C(C&& c) noexcept { std::cout << "C(C&&)\n"; } C(int, double) { std::cout << "C(int, double)\n"; } }; template<class T, class... Args> std::unique_ptr<T> make_unique(Args&&... args) { return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); } int main() { C c; auto p1 = make_unique<C>(); auto p2 = make_unique<C>(c); auto p3 = make_unique<C>(std::move(c)); auto p4 = make_unique<C>(1, 2.5); return 0; }
Insight:
Console: