Boost logo

Boost :

From: Jason Hise (chaos_at_[hidden])
Date: 2005-03-04 10:02:24


Martin wrote:

>I can't get the singleton to work with VC70.
>
>The error message is
>
>\boost\singleton\creators.hpp(171): error
>C2504: 'boost::singleton::detail::longevity_registry<Unused>' : base class
>undefined with [ Unused=void ]
>
>My code looks like:
>
>struct manipidx {
> manipidx() : idx(std::ios_base::xalloc()) { }
> int idx;
>};
>
>typedef basic_singleton<manipidx> tmanipidx;
>int main() {
> std::cout << tmanipidx::pointer()->idx << std::endl;
>}
>
>What I'm trying to do is to create a global variable that can be used in all
>instanses of a template and at the same time avoid the need for a .cpp file.
>
That's really strange, what you are trying to do should work. I think
there are computer labs at school which have VC70, I'll test your code
out there later today and see if I can't get it fixed. In the mean
time, have you tried using the singleton as a base class rather than a
typedef?

struct manipidx : boost::basic_singleton <manipidx> {
  manipidx() : idx(std::ios_base::xalloc()) { }
  int idx;
};

int main() {
  std::cout << manipidx::pointer()->idx << std::endl;
}

-Jason


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