|
Boost Users : |
Subject: Re: [Boost-users] How boost::tupe avoid compilor error of get member function?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-05-08 09:14:57
AMDG
simon Ye wrote:
> boost::tuple provide a member template function get to gain a element of
> tuple, As following:
>
> #include "boost\tuple\tuple.hpp"
> using namespace boost;
>
> template<typename T>
> class TA{public:
> template<typename T1, typename T2>
> void testfun(T1 e1, T2 e2)
> {
> tuple<T1, T2> t1(e1, e2);
> //T1 _e1 = t1.template get<0>(); //works
> *T1 _e1 = t1.get<0>(); //works for boost::tuple*
> /*
> However, according c++98, t1.get<0>() seems to should be encounter a
> compilor error.
> *I want to known how boost::tuple avoid this compile error.*
> */
> }
> };
>
The form that you've commented out is the correct syntax.
You cannot use just t1.get<0>() because tuple<T1, T2> is
a dependent type.
In Christ,
Steven Watanabe
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net