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 <string> class person { public: person(std::string name, std::string surname) : m_name{std::move(name)} , m_surname{std::move(surname)} {} private: std::string m_name, m_surname; }; template <typename T, typename... Args> T construct_v1(Args... args) { return T{args...}; } template <typename T, typename... Args> T construct_v2(const Args&... args) { return T{args...}; } template <typename T, typename... Args> T construct_v3(Args&&... args) { return T{std::move(args)...}; } int main() { auto name1 = std::string{"Jan"}; auto name2 = std::string{"Jan"}; auto name3 = std::string{"Jan"}; const auto surname = std::string{"Kowalski"}; auto p = construct_v1<person>(std::move(name1), surname); auto p2 = construct_v2<person>(std::move(name2), surname); auto p3 = construct_v3<person>(std::move(name3), surname); }
Insight:
Console: