Boost flyweight trouble

Started by
1 comment, last by lephyrius 14 years, 10 months ago
As you may have seen I try to use boost flyweight but it only gives me: " Assertion failed: (count()<=1), function ~refcounted_value, file /boost_1_39_0/boost/flyweight/refcounted.hpp, line 70. " I use Xcode on OS X to compile for iPhone. But here is what im doing: (really damn downstripped)

class Model {
public:

boost::flyweight<boost::flyweights::key_value<String,Texture,TextureNameExtractor> >** pages;
};


Model::Model() {

pages = new boost::flyweight<boost::flyweights::key_value<String,Texture,TextureNameExtractor> >* [1];

pages[0] = new boost::flyweight<boost::flyweights::key_value<String,Texture,TextureNameExtractor> > ("CoolModel");
}



I also tried with:

std::vector< boost::flyweight<boost::flyweights::key_value<String,Texture,TextureNameExtractor> > > pages;


But same result. Where do the destructor get called?
Advertisement
You've got pointers and other evil things, it's likely you did something wrong.

Write a testcase: the least amount of code that exhibits the problem with your original code. That means we can take your paste and pass it to a compiler.
Quote:Original post by loufoque
You've got pointers and other evil things, it's likely you did something wrong.

Write a testcase: the least amount of code that exhibits the problem with your original code. That means we can take your paste and pass it to a compiler.


I hate myself and I feel ashamed. When I wrote the testcase I discovered something in the constructor.

Model::Model() : pages(NULL) { }

That was the cause of the problem. I really don't know why but when I removed pages(NULL) it worked perfectly.

This topic is closed to new replies.

Advertisement