The relationship between auto and decltype

后端 未结 5 2119
礼貌的吻别
礼貌的吻别 2020-12-12 17:35

Is

auto x = initializer;

equivalent to

decltype(initializer) x = initializer;

or

decltype         


        
5条回答
  •  被撕碎了的回忆
    2020-12-12 17:55

    This won't work (and is ugly):

    decltype([]() { foo(); }) f = []() { foo(); };
    

    whereas

    auto f = []() { foo(); };
    

    will.

提交回复
热议问题