language: C++ 4.7.2 (gcc-4.7.2)
date: 338 days 13 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <cmath>
 
template<typename X> class A {
  X a;
public:
  A(X x) : a(x) {}
  template<typename Y>
  auto diff(A<Y> const&y) const -> decltype(a-y.a)
  { return a-y.a; }
};
 
template<typename X, typename Y>
inline auto dist(A<X> const&x, A<Y> const&y)
  -> decltype(std::abs(x.diff(y)))
{ return std::abs(x.diff(y)); }
 
int main()
{
  A<double> x(2.0), y(4.5);
  std::cout<<" dist(x,y)="<<dist(x,y)<<'\n';   //<-- error here
}
prog.cpp:9: warning: identifier ‘decltype’ will become a keyword in C++0x
prog.cpp:9: error: expected initializer before ‘->’ token
prog.cpp:15: error: expected initializer before ‘->’ token
prog.cpp: In function ‘int main()’:
prog.cpp:21: error: ‘dist’ was not declared in this scope