I have a type T
that has a member function fn
with a return type RT
. I have a template that takes T
and RT
as parameters. I'd like to alias this template class so that my code isn't so ugly and hard to read. How would I accomplish that?
template <typename X, typename Y>
struct I
{};
struct T
{
int& fn(int);
};
So I want to alias this or something like this type so I can write a function like this:
template <typename C>
I< typename std::remove_reference<std::decltype(std::declval(C).fn(0))>::type, C> fn(C& c)
{
return I< typename std::remove_reference<std::decltype(std::declval(C).fn(0))>::type, C>();
}
But with less mess. I've not used std::decltype
before, so I'm not even sure if I'm using it right as I was getting errors.
I was thinking about using a function like that and doing a decltype on it, but I was having some difficulty with it and I'd like it to look cleaner too.
Aucun commentaire:
Enregistrer un commentaire