Boost logo

Boost :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-05-06 13:53:14


AMDG

Simonson, Lucanus J wrote:
> //would not compile
> //template <int orient, typename T>
> //typename point_traits<T>::coordinate_type get(const T& point) {
> // return point_traits<T>::get<orient>(point);
> //}
>
> //will compile when written this way
> template <int orient, typename T>
> typename point_traits<T>::coordinate_type get(const T& point) {
> point_traits<T> traits_instance;
> return traits_instance.get<orient>(point);
> }
>
> int main() {
> point_data pt;
> //this line compiles
> int value0 = point_traits<point_data>::get<0>(pt);
> //this line now compiles
> int value = get<0>(pt);
> return 0;
> }
>
> But it still bugs me that I don't know why the compiler thought that
> point_traits<T>::get was a function pointer and tried to apply the
> operator< with orient, but does the right thing when I instantiate the
> traits struct and use the . operator to access the same function. The .
> operator could also produce a function pointer.
>

You need to use point_traits<T>::template get<0> inside a template.
The compiler should not accept the "." either, BTW.

In Christ,
Steven Watanabe


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk