Boost logo

Boost :

From: John Maddock (John_Maddock_at_[hidden])
Date: 2001-03-14 07:07:25


Jeremy,

I'm having a problem with the concept architypes classes, I want to
instantiate bidirectional_iterator_archetype<char> and
bidirectional_iterator_archetype<wchar_t>, but both fail to compile because
of the way boost::static_object is defined:

  template <class T>
  class static_object {
  public:
    static T& get() {
      detail::dummy_constructor d;
      static T x(d);
      return x;
    }
  };

As far as I can see this class is never documented (?), but you can't
instantiate the iterator architypes without specialising this object for
your particular type (or can you?). But surely I shouldn't be declaring
specialisations of library classes for non-UDT's ?

What would be wrong with defining this class as:

  template <class T>
  class static_object {
  public:
    static T& get() {
      static T x;
      return x;
    }
  };

Which would just plain work for all types that have default constructors...

- John Maddock
http://ourworld.compuserve.com/homepages/john_maddock/


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