Re: typename and sizeof
I doubt it. I certainly don't recall seeing it, and I can't think why
sizeof would somehow not require specification of dependent names that
are types.
well, 'A<T>::type' may be a type or a member, but
IMHO it's a bug in the EDG front end used by Comeau C++ - you could
report it to comeau@comeaucomputing.com.
strangely enough, this "hack" is used: for example, it's needed for static
assertions to work (and I think boost uses it).
roughly speaking, all static assertion implementations are based on an
incomplete type:
template <bool B> struct static_assert { typedef char type; };
template <> struct static_assert<false>;
from this point on, there are 2 alternative strategies:
1) the mosty common is
template <size_t N> struct dummy {};
#define STATIC_ASSERT(COND) typedef dummy<
sizeof(static_assert<(COND)>::type) > some_funny_name_t_
I think this is not a "hack" as meaning of the
static_assert<(boolean_expression)>::type is well defined and is not a
subject of the name resolution rules inside templates, in contrast to:
template<bool cond, template<bool> class a>
struct dummy_template
{
enum { v = sizeof(a<cond>::typename type) };
};
int v = dummy_template<(1 < 2), static_assert>::v;
I should note however that VC does not accept
enum x { v = sizeof(a<cond>::typename type) };
but
enum x { v = sizeof(a<cond>::type) };
Thus either I'm missing something or VC (and Comeau also) are wrong.
--
Vladimir Nesterovsky