Is this a specialized specialization of function templates?

I came up with this after answering this question

I had a simple function template (C ++ 11):

template<class elem_t, class list_t>
bool in_list(const elem_t& elem, const list_t& list) {
   for (const auto& i : list) {
      if (elem == i) {
         return true;
      }
   }
   return false;
}

But GCC issued warnings because it does not look like the output of a template parameter in the form of std :: initializer_list. Therefore, without hesitation, I made a specialization:

template<class elem_t>
bool in_list(const elem_t& elem, std::initializer_list<elem_t> list) {
   for (const auto& i : list) {
      if (elem == i) {
         return true;
      }
   }
   return false;
}

It worked. No more warnings. But when I looked again and thought about it, I remembered that C ++ does not support partial specialized specialization in function templates. But this is what it seems. My only assumption: this is allowed because std :: initializer_list is still dependent on the template parameter, so this is essentially a different template. But I'm not sure that this is how it should be (are there templates that do not overload?).

, ? ?

, GCC std:: initializer_list? , std:: initializer_list.

:

test.cpp: In functionint main()’:
test.cpp:33:43: warning: deducingconst list_tasconst std::initializer_list<int>’ [enabled by default]
test.cpp:6:6: warning:   in call tobool in_list(const elem_t&, const list_t&) [with elem_t = int, list_t = std::initializer_list<int>][enabled by default]
test.cpp:33:43: warning:   (you can disable this with -fno-deduce-init-list) [enabled by default]

in_list(3, {1, 2, 3, 4, 5});

: -, initializer_list GCC (cite). , : ++ 11? , , . !

EDIT2: , , GCC 4.7, , , , .

+3
2

, @Ben Voigt , :

§14.5.6.2

( ) . (.. ), , , .

, , , , . .

(3.2).

, .

§14.5.6.2.1

, * , (14.8.2) .

priming , , , in_list(a, b), b initializer_list, , .

(* , " " , , . , template<typename T> f();, f<int>() . )

, , , :

, :

- (13.3.3);

- ;

- , , new (3.7.4.2, 5.3.4);

- (14.5.4) (14.7.2) (14.7.3) .

, . , :

, , (. ) . , , . , - , .

, , , , , , , (, , , :)).

+4

. , .

+3

All Articles