views:

58

answers:

2

GCC has a very verbose format for certain template error messages:

... some_class<A,B,C> [with int A = 1, int B = 2, int C = 3]

Any chance to make it show something like:

... some_class<1,2,3>
+1  A: 

No, unless you are willing to maintain a private branch of GCC's source.

Although it is reasonable to want this for class templates, function templates may overload against each other and have different template argument lists for the same function. Then the latter style of error would be ambiguous.

Potatoswatter
+3  A: 

You will lose track from what template the specialization comes from:

template<int A, int B> class X {
  void f();
};

template<int A> class X<A, 2> {
  void f();
};

int main() {
  X<1, 2>().f();
  X<2, 1>().f();
}

GCC outputs

m.cpp: In function 'int main()':
m.cpp:6:12: error: 'void X<A, 2>::f() [with int A = 1]' is private
m.cpp:10:19: error: within this context
m.cpp:2:12: error: 'void X<A, B>::f() [with int A = 2, int B = 1]' is private
m.cpp:11:19: error: within this context

If it just said X<1, 2> and X<2, 1> you would lose an important information that this diagnostic contains.

Johannes Schaub - litb
uj2