Boost logo

Boost Users :

Subject: Re: [Boost-users] zip_iterator.hpp / boost::tuple requires a using namespace std!
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2012-02-29 17:32:03


> The gist of the problem is that the following template does not compile
> without the "using namespace std" statement:
>
> template <class T>
> struct MapZipHelperImpl
> {
> typedef typename boost::tuple< const T&, const T& > iter_value_type;
>
> void operator()( const iter_value_type& iter_value )
> {
> using namespace std; // without this the next line does not
> compile!
> typename T::first_type val = iter_value.get<0>().first ;
> }
> };
>
> The error is:
>
> error: expected primary-expression before ‘)’ token

The code is incorrect. For me, it doesn't compile even with the "using namespace std".

The correct code is:

typename T::first_type val = iter_value.template get<0>().first ;

Note the added "template" keyword.

Older versions of GCC may have been lenient accepting code like this without
the "template" keyword, but it has always been incorrect.

Regards,
Nate
                                               


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