DUChain and MTP

Patrick Staehlin me at packi.ch
Tue Feb 3 22:26:43 UTC 2009


Hi,

the following meta-template compiles fine in g++ (well actually it might not 
because it's copy-pasted out of a bigger file but still demonstrates the 
issue) but DUChain stumbles over it:

test.cpp
----------------
template <int N, int limit>
struct SeriesAdder
{
  enum { value = N + SeriesAdder< (limit > 1) ? N - 1 : 0, (limit > 1) ? limit 
- 1 : 0>::value };
};

template <>
struct SeriesAdder<0, 0>
{
  enum { value = 0 };
};

void test() {
  SeriesAdder<50,1>::value;
}
----------------

To reproduce store it to test.cpp and open it in KDevelop4 (might be obvious 
;-)...

Messages:
----------------
Expected token '}' after ',' found '(', test.cpp:4 col:60
Expected token ';' after 'identifier' found '>', test.cpp: col:67
Unexpected token '-', test.cpp:4 col:80
Unexpected token '}', test.cpp:4 col:97
----------------

Adding extra brackets around the conditions makes DUChain happy:
----------------
  enum { value = N + SeriesAdder< ((limit > 1) ? N - 1 : 0), ((limit > 1) ? 
limit - 1 : 0) >::value };
----------------

Should I open a bug in Bugzilla or is it actually g++ who's not adhering to 
the standard?

Patrick

PS: Nice work on KDevelop4, I really like improved code-completion!




More information about the KDevelop-devel mailing list