Search code examples
c++oopboostbigdatastxxl

Boost noncopyable error when creating STXXL maps


I have been doing some work with STXXL, and I've kind of encountered a problem with the maps inheriting from boost::noncopyable... For this project, I create several maps with the statement:

stxxl::map<int, mapData, CmpIntGreater, 4096, 4096> node_map((stxxl::unsigned_type)(4096 * 4), (stxxl::unsigned_type)(4096 * 3));

Needless to say the hard coded values in the constructor will be replaced once I solve this problem, but in any case, I get the error:

C2248: 'boost::noncopyable_::noncopyable::noncopyable' : cannot access private member declared in class 'boost::noncopyable_::noncopyable'

Has anyone else encountered this problem with STXXL maps? Or does anyone have some general advice or best practices when working with noncopyable objects?

Thanks for all your help guys :)


Solution

  • Just to add an official answer here to accept, my problem was that I had some functions returning maps by value and some function arguments being passed by value. Once this was fixed, it worked like a charm! So, moral of the story, when using a version of STXXL that inherits from noncopyable, make sure that all instances of your STXXL object are used with your functions by reference only, not by value.