0

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 :)

Andrewziac
  • 155
  • 2
  • 16
  • Just like the compiler says, you attempt to copy a non-copyable object (eg. passing/returning it by value or using assignment). Show the relevant code. – Igor R. Oct 08 '13 at 05:14
  • Unfortunately, the compiler isn't pointing to a line in my code, but rather a line in the STXXL map.h code (line 363, basically right at the end of the map class definition, so pretty unhelpful). I guess what want to make sure of is whether it would be my instantiation that I showed above that is causing this error, or whether it would be somewhere else in my code. As long as its not my instantiation, I'm sure I can find the error :) – Andrewziac Oct 08 '13 at 11:42
  • 1
    The `node_map` object definition looks ok. Look for places where you pass it by value to a function. Or maybe it's a member of another object, which you forgot to make explicitly non-copyable. – Igor R. Oct 08 '13 at 13:23
  • BTW, `stxxl::map` doesn't seem to be non-copyable at all (http://algo2.iti.kit.edu/dementiev/stxxl/doxy/html/map_8h-source.html). So it's probably the error reason is in some other place... – Igor R. Oct 08 '13 at 13:56
  • Thanks, but I think your link is for an outdated version. I'm using 1.3.1 which specifically inherits from boost::noncopyable. In any case, I found what my problem was (Had some functions returning by value some function arguments passed by value) and now my program is working like a charm, thanks for all your help! – Andrewziac Oct 08 '13 at 15:48

1 Answers1

0

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.

Andrewziac
  • 155
  • 2
  • 16