0
//class we're trying to generate
template <int a, foo b>
class A
{
public:
  A()
  {
    std::cout << a << "," << (int)b << std::endl;

  }
};

//class which generates information
template <typename T>
struct B
{
  typedef T value_type;
  static const T val;
};

template <typename... B>
struct madscience_intitializer
{
  template <typename B::value_type... args>
  using ret_type = A<args...>;
};

int main()
{
  madscience_intitializer<B<int>,B<foo> >::ret_type<1,foo::y> a;
}

G ++では、私は得る

/home/njclimer/source/testdir/main/main2.cpp: In function 'int main()':
/home/njclimer/source/testdir/main/main2.cpp:38:61: internal compiler error: in dependent_type_p, at cp/pt.c:19526
madscience_intitializer<B<int>,B<foo> >::ret_type<1,foo::y> a;


Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
Preprocessed source stored into /tmp/ccAhk6TK.out file, please attach this to your bugreport.

他の誰かがこれに遭遇しましたか?これはコンパイラの実際のバグですか、それとも私のコードのバグですか?

私は走っています

g++ (GCC) 4.8.2 20131212 (Red Hat 4.8.2-7)
                                                         ^

フラグ付き -std=gnu++0x -O2 -g

4

1 に答える 1

-1

明らかに、コンパイラはクラッシュしないはずですが、とにかくコードはコンパイルされないと思います。

非整数型をテンプレート パラメーターとして渡すことはできません。これは次のとおりです。

ret_type = A; を使用したテンプレート。

する必要があります

ret_type = A; を使用します。

于 2014-02-11T19:31:02.673 に答える