Alias for a template struct inside another template struct

  alias, c++, templates

I want to write a function type that transform a type B in the same type but with the same sign that another type A. I can achieve that using this function:

template <typename A, typename B, bool = std::is_signed_v<B>>
struct same_sign_as{
    using type = std::make_signed_t<A>;

template <typename A, typename B>
struct same_sign_as<A, B, false>{
    using type = std::make_unsigned_t<A>;

and then use it as using R = same_sign_as_t<A,B>;.

But I want my code to be readable. When I see a function simliar to same_sign_as I never know if it means the type A with the sign of B or the type of B with the sign of A.

As I don’t want to remember this kind of things I’d like to write better something similar to

using R = make_type<A>::same_sign_as<B>

With this I’m not going to make any mistakes.

Is easy to write it:

template <typename A>
struct make_type{
    template <typename B>
    struct same_sign_as
    { using type = typename __same_sign_as<A, B>::type; };

where I changed the name of same_sign_as for __same_sign_as (I want this function to be an implementation detail).

To use make_type write:

using Res = typename make_type<A>::template same_sign_as<B>::type

and that is horrible. You can’t read that!!!

Can I define an alias to achieve my goal of writing using Res = make_type<A>::same_sign_as<B>?

Source: Windows Questions C++