Partial specialization is no more specialized.

To my surprise, I had an error when I tried to compile this code with GCC 7.2.0.

the code:

#include <typeinfo>
#include <iostream>
#include <utility>

template <typename Seq, typename Seq::value_type Inc> struct increment;
template <typename T, T... I, T Inc>                                   
struct increment<std::integer_sequence<T,I...>, Inc> {                 
  using type = std::integer_sequence<T,(I+Inc)...>;                    
};                                                                     

int main(int argc, char* argv[]) {
  typename increment<std::make_index_sequence<2>,1>::type seq;
  std::cout << typeid(seq).name() << std::endl;
}

Error:

error: partial specialization 'struct increment<std::integer_sequence<T, I ...>, Inc>' is not more specialized than [-fpermissive]
 struct increment<std::integer_sequence<T,I...>, Inc> {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
spec.cc:5:62: note: primary template 'template<class Seq, typename Seq::value_type Inc> struct increment'
 template <typename Seq, typename Seq::value_type Inc> struct increment;
                                                              ^~~~~~~~~

I have been using for incrementquite some time with GCC 6.2.0no problem.

Which one is correct? If GCC 7true, how can I write this metafunction?

+4
source share

Source: https://habr.com/ru/post/1687100/


All Articles