13:05 - this issue can be easily resolved using auto for the return type. template auto concat(const T& a, const T& b) { return a + b; } ... Which means that auto _should_ be your first choice as a return type fort such templates.
@MrM12LRV6 жыл бұрын
This guy is so cool
@gast1286 жыл бұрын
Good talk though I would hope they focus more on libraries and build times then yet another template trick.
@christophrcr6 жыл бұрын
20:10 -> How does this change affect the lifetime of the result of compute(t)?
@YourCRTube6 жыл бұрын
It has its life extended like a const &
@Lecopivo6 жыл бұрын
Is there a nice way to implement the print function such that it can be called without a single argument? i.e. print() is valid.
@atib19806 жыл бұрын
Here is my first attempt at coding a simple short variadic function template for such a print function: template int print(ConstCharPointerType format = " ", Args&&... args) { static_assert(is_same::value || is_same::value, "Specified format parameter's type (template parameter " "'ConstCharPointerType') must be either const char* or const " "wchar_t*!"); if constexpr (is_same::value) { return printf(format, std::forward(args)...); } if constexpr (is_same::value) { if (!strcmp(format, " ")) format = L" "; return wprintf(format, std::forward(args)...); } } // or here is one possible simple implementation for a python like print function using 2 variadic function templates: void printArgument() { cout