const在const中的用途是什么? decltype(T + U)?

时间:2017-11-02 14:29:50

标签: c++ c++11 templates const decltype

#include<functional>
#include<iostream>
#include<string>

struct Polly
{
    template<typename T,typename U>
    auto operator()(T t,U u) const -> decltype(t+u)
    {
        return t+u;
    }
};

int main()
{
    auto polly=std::bind(Polly(),std::placeholders::_1,"confunsing");

    std::cout<<polly(4)<<polly(std::string(" this is "))<<std::endl;
}

现在我不明白const的用法:const - &gt; decltype(T + U)。我使用decltype能够返回多种类型的数据。

0 个答案:

没有答案
相关问题