0
#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;
}

Now I don`t understand the use of const here: const -> decltype(t+u). I am using decltype to be able to return multiples types of data.

Yakk - Adam Nevraumont
  • 262,606
  • 27
  • 330
  • 524

0 Answers0