int&& type_(){} int& type__(){} const int type___(){} int main() { int a = 42; const int ac = 42; int& b = a; int&& c = 42; decltype(a) a_= 10; // int , name decltype((a)) a__ = a; // int& , expression of l-value, referenced decltype(b) b_ = a; // int& , name decltype((b)) b__ = a; // int&& => int& , expression of l-value, referenced decltype(c) c_ = 10; // int&& , name decltype((c)) c__ = a; // int&&& => int& , expression of l-value, referenced decltype(ac) ac_ = 10; // const int decltype(type_()) type_ = 10; // int&&, if const int&&, then type is const int&& decltype(type__()) type__ = ac; // int&, if type__() returns const int&, then const int& decltype(type___()) type___ = 10; // int , copy by value, ignore c.v }Reference: C++ Type Deduction and Why You Care, Scott Meyers When decltype meets auto
Jun 9, 2014
[C++11] decltype
Labels:
cpp,
cpp_note,
cpp11,
cpp11_auto,
cpp14,
cpp14_auto
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.