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

Do nonmember nonfriend functions improve genericity?

P: n/a
The author's reason is "because its hard to write templates that dont
know whether or not an operation is a member for a given type". What
does he mean by this? An example is appreciated.

Jul 29 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
bl**********@gmail.com wrote:
The author's
The author of what?
reason is "because its hard to write templates that dont
know whether or not an operation is a member for a given type". What
does he mean by this? An example is appreciated.


What is the context?

If I had to speculate, the "author" you're quoting (?) speaks of template
code similar to

template<class T> void foo(T t)
{
// if T has a member 'bar', use it
t.bar();
// else, don't use it, use some global function
::bar(t);
}

Such template is rather difficult to implement, but possible, using SFINAE
technique. Look up "has_member" in the archives.

V
Jul 29 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.