Boost logo

Boost :

From: Mark Rodgers (mark.rodgers_at_[hidden])
Date: 2000-05-25 14:36:03


From: David Abrahams <abrahams_at_[hidden]>
> In my neck of the woods we call that class "namespace" ;)
> Seriously, why not use a namespace?

Of course namespaces suffer the problem that you can't use them as
template parameters, so if I want to write

  template <typename T>
  int foo() { T::bar(); }

Then I can't write

  namespace fred { void bar(){} }
  foo<fred>();

But I could write

  struct fred : private noninstantiable { static void bar(){} };
  foo<fred>();

Perhaps it should be a guideline that one should prefer classes
with static members over namespaces when possible???

However, I find it hard to imagine what harm would come from
instantiating fred above, so wonder why we need to take the
trouble to prevent it.

Mark


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