# Boost flyweight trouble

This topic is 3414 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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?

##### Share on other sites
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.

##### Share on other sites
Quote:
 Original post by loufoqueYou'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.

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 10
• 10
• 14
• 10
• 25
• ### Forum Statistics

• Total Topics
632647
• Total Posts
3007640
• ### Who's Online (See full list)

There are no registered users currently online

×