Enlightening Usage of C++11 decltype

后端 未结 3 1761
醉梦人生
醉梦人生 2020-12-15 07:46

I\'ve just seen this really nice talk Rock Hard: C++ Evolving by Boris Jabes. In the section of the talk concerning Higher-Order Generic Programming he say

3条回答
  •  暖寄归人
    2020-12-15 08:32

    One place that I use it, is where I need to make a variable that must have same type of another variable . but I'm not sure if in future the type will stay same or not .

    void foo(int a)//maybe in future type of a changed
    {
        decltype(a) b;
        //do something with b
    }
    

提交回复
热议问题