template lookup второго порядка
От: saf_e  
Дата: 28.12.20 14:43
Оценка:
Всем привет.

не знаю как правильно это называется, но хочется чтобы в test then<int> <int> можно было не указывать:

#include <type_traits>
#include <future>

template<typename F,
                std::enable_if_t<std::is_same<typename std::result_of<F()>::type, void>::value, bool> = true>
void then(F objL_callback)
{
}

template<typename X, typename F, 
            std::enable_if_t<std::is_same<typename std::result_of<F()>::type, std::future<X>>::value, bool> = true>
void then(F objL_callback)
{
}

void test()
{
    then<int>([]
    {
        return std::future<int>();
    });

    then([]
    {
    });
}


Есть идеи?
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.