0

I saw code in the standard library where the template was declared but the typename was not specified.

https://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.2/cpp__type__traits_8h-source.html

00211   template<>
00212     struct __is_integer<int>
00213     {
00214       enum { __value = 1 };
00215       typedef __true_type __type;
00216     };

A name used in a template declaration or definition and that is dependent on a template-parameter is assumed not to name a type unless the applicable name lookup finds a type name or the name is qualified by the keyword typename.

source: Where and why do I have to put the "template" and "typename" keywords?

If this is the following, what is the use of this code? Why did they put in a template<> that you don't use?

Evg
  • 25,259
  • 5
  • 41
  • 83
hochan
  • 220
  • 3
  • 10
  • 2
    You might have missed L147-155. – chris Apr 30 '21 at 05:09
  • 1
    Ah... I missed the top. Thank you. ps: It's about Template specialization https://www.cplusplus.com/doc/oldtutorial/templates/ – hochan Apr 30 '21 at 05:15
  • 2
    This is a [template specialization](https://en.cppreference.com/w/cpp/language/template_specialization) of a `template struct __is_integer;`. – Scheff's Cat Apr 30 '21 at 05:16

1 Answers1

0

Thanks to @Scheff, @chris.

This is a template specialization of a template <typename T> struct __is_integer;

https://www.cplusplus.com/doc/oldtutorial/templates/ https://en.cppreference.com/w/cpp/language/template_specialization

00147   //
00148   // Integer types
00149   //
00150   template<typename _Tp>
00151     struct __is_integer
00152     {
00153       enum { __value = 0 };
00154       typedef __false_type __type;
00155     };
hochan
  • 220
  • 3
  • 10