what are the differences between returning auto, auto&, auto&& and decltype(auto)?

what are the differences between returning auto, auto&, auto&& and decltype(auto)?

for instance:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
auto f(int val) { 
static int value = val;
return value;
}
auto& f(int val) { 
static int value = val;
return value;
}
auto&& f(int val) { 
static int value = val;
return value;
}
decltype(auto) f(int val) { 
static int value = val;
return value;
}


??
Topic archived. No new replies allowed.