
Hello, I first present to you my code and I will explain my problem with the code . ShmString.h : namespace ip=boost::interprocess; typedef ip::allocator<char, ip::managed_shared_memory::segment_manager> CharAllocator; class ShmString : public ip::basic_string<char, std::char_traits<char>, CharAllocator > { public: ShmString (); virtual ~ShmString (); /** * The segment to build the string */ static ip::managed_shared_memory* st_segment; } This class served to have some string in memory. The following Element.h used it : class Element { public: Element (const std::string dir, const std::string type, ip::managed_shared_memory * segment); private: ShmString dir; ShmString file; ShmString type; ip::managed_shared_memory * segment; }; I have four attributes that declare it. When I tried to define all the attributes in the constructor like this in Element.cpp : Element::Element (const string dir, const string file, const string type, ip::managed_shared_memory *segment){ try{ this->dir.assign(dir.c_str()); this->file.assign(file.c_str()); } catch(ip::interprocess_exception &e){ ostringstream oss; const std::string what(e.what()); oss << "Class Element in constructor 1 -> "; oss << what; throw EventException(oss.str().c_str(), __LINE__ ); } } If for example "const string dir " has the size more than 10 (the capacity by default for a ShmString object), I obtained an error like this : x0807436f in boost::interprocess::basic_string<char, std::char_traits<char>, boost::interprocess::allocator<char, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void>, 0u>, boost::interprocess::iset_index>
::assign (this=0xb7428274,
s=0xb9adf154 <Address 0xb9adf154 out of bounds>) I tried to used the other constructors by default for basic_string but it remains the same. This code only works when in the constructors the string size are below 10. Could you someone explain me why I obtain this? Do I have some faulty code? Could you provide some examples on how store string with interprocess::basic_string in shared memory for a size for more than 10 characters? I will be very grateful because I am lost... Thanks you in advance Regards Samuel -- View this message in context: http://www.nabble.com/boost%3A%3Ainterprocess%3Abasic_string-%3A-Capacity-no... Sent from the Boost - Users mailing list archive at Nabble.com.