decltype-auto Questions
1
Consider this simple self-contained code:
template<typename T>
void foo();
void bar() {
int i;
auto l = [&i]() -> decltype(auto) {
decltype(auto) x = i;
foo<decltype(x)>();
...
Rundlet asked 16/5, 2022 at 23:58
1
decltype(auto) func(int&& n)
{
return (n);
}
clang 12.0.1 accepts this code, but gcc 11.2.1 rejects it with:
error: cannot bind rvalue reference of type 'int&&' to lvalue of type ...
Absurdity asked 24/1, 2022 at 14:38
4
(This is a follow-up from "Are there any realistic use cases for `decltype(auto)` variables?")
Consider the following scenario - I want to pass a function f to another function invoke_log_return w...
Sphacelus asked 10/8, 2019 at 18:59
1
Solved
I am trying to make template wrapper function, that should forward parameters and return value. And I can't decide what is better to use auto&& or decltype(auto) for return type. I've read ...
Diddle asked 26/9, 2021 at 13:40
3
I am learning C++17 new feature decltype(auto) for non-type template parameter. I wrote a simple code snippet as following:
#include <type_traits>
template<decltype(auto) arg>
struct F...
Xylograph asked 18/10, 2020 at 16:49
2
Solved
Both from my personal experience and from consulting answers to questions like What are some uses of decltype(auto)? I can find plenty of valuable use cases for decltype(auto) as a function return ...
Airport asked 9/8, 2019 at 23:40
2
Solved
In c++14 the decltype(auto) idiom is introduced.
Typically its use is to allow auto declarations to use the decltype rules on the given expression.
Searching for examples of "good" usage of the...
Allies asked 8/6, 2014 at 19:0
1
© 2022 - 2025 — McMap. All rights reserved.