By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,255 Members | 2,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,255 IT Pros & Developers. It's quick & easy.

Template member operators.

P: n/a
Is the following construct legal? If yes how does one actually call the
operator? I've tried quite a few variations on way of calling this, all
to no avail.

class Foo {
public:
template <typename Tconst T& operator*() const
};

Thanks,
Alan
Sep 14 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Appologies:

Alan Woodland wrote:
This line:
template <typename Tconst T& operator*() const
Should read as:

template <typename Tconst T& operator*() const;

Alan
Sep 14 '06 #2

P: n/a
Alan Woodland wrote:
Is the following construct legal? If yes how does one actually call the
operator? I've tried quite a few variations on way of calling this, all
to no avail.

class Foo {
public:
template <typename Tconst T& operator*() const
};
class Foo {
public:
template <typename Tconst T& operator*() const
{}
};

int main ( void ) {
Foo f;
f.operator*<int>();
}
Best

Kai-Uwe Bux
Sep 14 '06 #3

P: n/a
Kai-Uwe Bux wrote:
Alan Woodland wrote:
>[..]

class Foo {
public:
template <typename Tconst T& operator*() const
{}
{ return T(); } // or something, otherwise it has UB
};

int main ( void ) {
Foo f;
f.operator*<int>();
}
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Sep 14 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.