File: gcc_template_specialization_operator_overload.cc

package info (click to toggle)
libsigc%2B%2B-2.0 2.12.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,432 kB
  • sloc: cpp: 4,132; xml: 339; python: 196; makefile: 192; sh: 5
file content (37 lines) | stat: -rw-r--r-- 627 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Configuration-time test program, used in Meson build.
// Corresponds to the M4 macro SIGC_CXX_GCC_TEMPLATE_SPECIALIZATION_OPERATOR_OVERLOAD.

#include <iostream>

class Thing
{
  public:
  Thing()
  {}

  template <class T>
  void operator()(T a, T b)
  {
    T c = a + b;
    std::cout << c << std::endl;
  }
};

template<class T2>
class OtherThing
{
public:
  void do_something()
  {
     Thing thing_;
     thing_.template operator()<T2>(1, 2);
     //This fails with or without the template keyword, on SUN Forte C++ 5.3, 5.4, and 5.5:
  }
};

int main()
{
  OtherThing<int> thing;
  thing.do_something();
  return 0;
}