Re: Templates question
Re: Templates question
- Subject: Re: Templates question
- From: Ladd Van Tol <email@hidden>
- Date: Sun, 25 Feb 2007 00:10:21 -0800
On Feb 24, 2007, at 11:15 AM, David Fang wrote:
Visual C++ also permits some crazy things like pointer-to-member-
function as a template argument. I've actually seen this used in
someone else's code too.
template <typename T, typename C, T (C::*getter)() const> class
CrazyTemplate
{
};
That's not crazy, that's standard, conventional C++.
<insert witty comment about the relativity of craziness here>
Any C++ compiler that doesn't support it, isn't a C++ compiler.
Sorry, my example was incomplete, but implied above:
class Tapir
{
int getSomething() const;
CrazyTemplate<int, Tapir, getSomething> flyingAlpaca;
};
As far as I can tell, this is disallowed by the C++ standard. VC++
swallows it whole.
GCC has this to say:
template.cpp:11: error: 'int Tapir::getSomething() const' cannot
appear in a constant-expression
template.cpp:11: error: template argument 3 is invalid
- Ladd
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden