Я не понимаю, почему это не компилируется:
struct A
{};
template<class T>
struct B
{};
template<template<class> class T1, class T2>
struct C
{};
int
main (int ac, char **av)
{
typedef B<double> b; //compiles
typedef B<const double> b_const; //compiles
typedef B<A> ba; //compiles
typedef B<const A> ba_const; //compiles
typedef C<B,double> c1; //compiles
typedef C<B,const double> c2; //compiles
typedef C<const B,double> c3; //ISO C++ forbids declaration of ‘type name’ with no type
}
(я нахожу ссылку на стандарт немного загадочной)
Что мне нужно изменить, чтобы он компилировался?
EDIT:
Сведения о компиляторе (похоже, что это подходит):
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.4.4-14ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5)
EDIT2:
С помощью объяснения я пытаюсь сделать что-то вроде этого:
template<template<class> class TheContainer, class T>
struct Iterator
template<class T>
struct Container
typedef Iterator<Container, double> iterator;
typedef Iterator<const Container, double> const_iterator;
Техника для не шаблонных контейнеров находится в конце этого документа: http://www.boost.org/doc/libs/1_46_1/libs/iterator/doc/iterator_facade.html
Я думаю, что решение не в том, чтобы прижимать шаблоны. Оглядываясь назад, это кажется очевидным.