Boost logo

Boost :

Subject: Re: [boost] Help! Detecting that two template aliases are equal.
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2012-11-03 02:58:26

> > I haven't checked this, but it's the behavior that I would expect.
> That seems surprising to me. It's a simple alias here, so I would expect it
> to be exactly that -- an alias. If I make a typedef of a type, I expect it
> to alias that type such that is_same tells me that are the same (which it,
> of course, does). An alias should, whenever possible, be exactly that, an
> alias.

Suppose you have an alias of the form

template <typename T>
using alias = typename some_metafunction<T>::type;

It could very well be that some_metafunction<T>::type is foo<T> for
all types T (where foo is some class template), but it's undecidable for
the compiler to determine that in the general case.

So, in the general case, it is not reasonable to expect a compiler to
deem 'alias' and 'foo', as template *template* parameters, to be equal
(of course for any T, the template *type* parameters alias<T> and
foo<T> *will* be equal).

Given that this is the case, it would be strange if, as a special case,
the compiler did deem 'alias' and 'foo', as template template parameters,
to be equal if 'alias' happened to be defined as follows:

template <typename T>
using alias = foo<T>;

I think the behaviour you're experiencing, while undesirable for your
particular use case, is consistent.


Boost list run by bdawes at, gregod at, cpdaniel at, john at