template alias error
Apr 17, 2017 at 3:50pm UTC
I have written the following code:
1 2 3 4 5 6 7 8
template <typename Val>
struct Forward
{
/// ...
};
template <typename Val>
using Value_type<Forward<Val>> = Val;
However, I get the following compilation error on the last LoC:
error: expected '=' before '<' token|
error: expected type-specifier before '<' token|
error: expected unqualified-id before '<' token|
What is wrong with the LoC that includes the Value_type declaration?
This example is taken from Stroustrup's book.
Thanks.
Apr 17, 2017 at 4:13pm UTC
1 2 3 4 5 6 7
template < typename T > struct Value_type { /* ... */ };
template < typename T > struct Forward { /* ... */ };
template < typename T > using Val = Value_type< Forward<T> > ;
static_assert ( std::is_same< Val<int >, Value_type< Forward<int > > >::value, "unexpected" ) ;
Apr 17, 2017 at 4:25pm UTC
clang gives a more sensible message: "error: partial specialization of alias templates is not permitted". This looks like a bug in the book: using a language feature that was going to, but didn't quite make it into the standard.
Topic archived. No new replies allowed.