This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Non-type template parameters not being matched; partial specialization missed
- From: Phil Edwards <phil at jaj dot com>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 23 Jan 2003 15:59:54 -0500
- Subject: Non-type template parameters not being matched; partial specialization missed
The following snippet of code is taken directly from Loki. Boost and a
couple of other similar homegrown libraries scattered around the 'net do
something similar.
fenric 183% cat nontype.cc
template <typename T>
struct is_member_pointer
{ enum { v = false }; };
template <typename T, typename U>
struct is_member_pointer<U T::*>
{ enum { v = true }; };
struct StaticMember
{
static int data;
static int function (int) { return 42; }
};
bool testd = is_member_pointer< &StaticMember::data >::v;
bool testf = is_member_pointer< &StaticMember::function >::v;
fenric 184% build/install-2003-01-22-trunk/bin/g++ -c nontype.cc
nontype.cc:16: error: type/value mismatch at argument 1 in template parameter
list for `template<class T> struct is_member_pointer'
nontype.cc:16: error: expected a type, got `&StaticMember::data'
nontype.cc:16: error: `v' is not a member of `<declaration error>'
nontype.cc:17: error: type/value mismatch at argument 1 in template parameter
list for `template<class T> struct is_member_pointer'
nontype.cc:17: error: expected a type, got `StaticMember::function(int)'
nontype.cc:17: error: `v' is not a member of `<declaration error>'
fenric 185%
I have the distinct feeling I'm forgetting something, but what?
Phil
--
I would therefore like to posit that computing's central challenge, viz. "How
not to make a mess of it," has /not/ been met.
- Edsger Dijkstra, 1930-2002