Boost logo

Boost :

From: Eric Weitzman (eweitzman_at_[hidden])
Date: 2000-11-01 12:28:39


[Intro to Advanced C++ Template Techniques 101.]

Is there a a technique for defining a static data member for a template
class other than using some macro kludge or requiring manual code inserted
into an implementation file? For example

    in C.h:

      template <class T>
      class C {
          static int i_;
      };

      #define DEFINE_STATIC_C(_t) int C<_t>::i_ = 0;

    in C.cpp:

      typedef C<blah> MyC;
      int MyC::i_ = 0; // how can one avoid doing this?
      int C<blah>::i_ = 0; // ... or this?
      DEFINE_STATIC_C(blah); // ... or this?

I'm looking for some technique that permits the static definition in the
header without having it defined in multiple program units.

Thanks,
- Eric


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