tuple<...involves template par...>

Hi,
I have the following:
template<typename T>
class A: public std::unary_function

On Feb 12, 2008 3:08 PM, e r
Hi,
I have the following:
template<typename T> class A: public std::unary_function
&, void>{ public: typedef typename std::unary_function &, void> parent_type; typedef typename parent_type::argument_type argument_type; void operator()(argument_type t)const{ t.get<0>(); //error: expected primary-expression before ')' token t.get<1>(); //error: expected primary-expression before ')' token }; };
Similar code without the template (i.e. fix say T = double) works fine.
I'm taking a wild guess here not knowing what you're running this on (and I really haven't looked into your code much), but try: t.template get<0>(); t.template get<1>(); Was that it? Stjepan

Stjepan Rajko wrote:
On Feb 12, 2008 3:08 PM, e r
wrote: Hi,
I have the following:
template<typename T> class A: public std::unary_function
&, void>{ public: typedef typename std::unary_function &, void> parent_type; typedef typename parent_type::argument_type argument_type; void operator()(argument_type t)const{ t.get<0>(); //error: expected primary-expression before ')' token t.get<1>(); //error: expected primary-expression before ')' token }; };
Similar code without the template (i.e. fix say T = double) works fine.
I'm taking a wild guess here not knowing what you're running this on (and I really haven't looked into your code much), but try:
t.template get<0>(); t.template get<1>();
Was that it?
Stjepan
It compiles w/o error. Thanks!

I'm taking a wild guess here not knowing what you're running this on (and I really haven't looked into your code much), but try:
t.template get<0>(); t.template get<1>();
Was that it?
Stjepan
It compiles w/o error. Thanks!
_______________________________________________
Is it possible for the boost/template gurus to explain why it is needed here? Any help would be appreciated, -- - Kobi

On Feb 13, 2008 12:05 PM, Kobi Cohen-Arazi
I'm taking a wild guess here not knowing what you're running this on (and I really haven't looked into your code much), but try:
t.template get<0>(); t.template get<1>();
Was that it?
It compiles w/o error. Thanks!
Is it possible for the boost/template gurus to explain why it is needed here?
http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/topic/com.ibm.xlcpp... --Michael Fawcett

On Feb 13, 2008 12:05 PM, Kobi Cohen-Arazi
wrote: I'm taking a wild guess here not knowing what you're running this on (and I really haven't looked into your code much), but try:
t.template get<0>(); t.template get<1>();
Was that it?
It compiles w/o error. Thanks!
Is it possible for the boost/template gurus to explain why it is needed here?
http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/topic/com.ibm.xlcpp...
--Michael Fawcett
Thank you! It's very helpful! Max
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On Wednesday 13 February 2008 19:05:16 Kobi Cohen-Arazi wrote:
I'm taking a wild guess here not knowing what you're running this on (and I really haven't looked into your code much), but try:
t.template get<0>(); t.template get<1>();
Was that it?
Stjepan
It compiles w/o error. Thanks!
_______________________________________________
Is it possible for the boost/template gurus to explain why it is needed here?
Any help would be appreciated,
I'm no template guru but (the same as typename), template may be used in such contexts to tell the compiler that the following _dependent_ name (ie "get") is to be treated as a template and not (as it assumes by default) as say a data member. Because if it was a data member then get<0 actually means operator<(get, 0) and not part of the syntax to instantiate the template "get". So then you must tell the compiler "get" is a template. Notice I underlined "dependent", it means this is needed in contexts where the name depends on a template parameter, so if "t" is of a template parameter type (or dependent on such a parameter) then the compiler cannot know in "t.name", if "name" is suposed to be a member, a nested non-template type or a template (class or function, doesn't matter). It will require additional specification from you (otherwise assumes to be a member, except some contexts in which it assumes to be a non-template type), in our case it requires that we tell it that "get" is a template for all "t"s possible in that context. I hope I got it right... -- Mihai RUSU Email: dizzy@roedu.net "Linux is obsolete" -- AST
participants (6)
-
dizzy
-
e r
-
Kobi Cohen-Arazi
-
Max
-
Michael Fawcett
-
Stjepan Rajko