Boost logo

Boost :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2006-01-27 20:08:39


Hmm...

I had the impression that it's impossible to register
default-parameter-versions of forward-declared templates. But this
impression was caused by my experience with STL registration, where all
default parameters are provided in the class definitions, and I was
obviously not able to change this. But it looks possible to specify them in
the declarations (verified with vc71, gcc, and comeau online), so the
following code is compiles:

---------------------------------------------
#define BOOST_TYPEOF_COMPLIANT
#include <boost/typeof/typeof.hpp>

template<class T, class U = T*, class V = U*>
struct x;

#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()

BOOST_TYPEOF_REGISTER_TEMPLATE(x, 1)
BOOST_TYPEOF_REGISTER_TEMPLATE(x, 2)
BOOST_TYPEOF_REGISTER_TEMPLATE(x, 3)

template<class T, class U, class V>
struct x
{};

typedef BOOST_TYPEOF(x<int>()) type1;
typedef BOOST_TYPEOF((x<int, short>())) type2;
typedef BOOST_TYPEOF((x<int, short, char>())) type3;

int main()
{}
---------------------------------------------

If this code is portable, I would say it definitely seems more preferable
for default parameter registrations than anything we discussed so far.

Regards,
Arkadiy


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk