Opened 7 years ago

Closed 7 years ago

#11713 closed Bugs (invalid)

boost::interprocess::basic_string instantiation broken (wrong report - please close ticket!)

Reported by: kaparis.dimitri@… Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.59.0 Severity: Regression
Keywords: Cc:

Description

It appears that instantiation of boost::container::basic_string's with shared memory segment allocators doesn't work in 1.59:

#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/containers/string.hpp>

    typedef boost::interprocess::managed_shared_memory::segment_manager
            SegmentManagerT;
    typedef boost::interprocess::allocator<char,SegmentManagerT>
            CharAllocatorT;

    typedef boost::interprocess::basic_string<char,
                                              std::char_traits<char>,
                                              CharAllocatorT>
            StringT;

void test2(CharAllocatorT& alloc)
{
    StringT s("", alloc);
}

Gives error on s instantiation. Using g++ (Ubuntu 4.9.2-10ubuntu13) 4.9.2

This compiles cleanly with Boost 1.57. Haven't tried 1.58

Change History (4)

comment:1 by kaparis.dimitri@…, 7 years ago

The same problem affects example 33.10 of the chapter on Managed Shared Memory of "The Boost C++ Libraries" book (http://theboostcpplibraries.com/boost.interprocess-managed-shared-memory):

#include <boost/interprocess/managed_shared_memory.hpp>
#include <iostream>

using namespace boost::interprocess;

int main()
{
  shared_memory_object::remove("Boost");
  managed_shared_memory managed_shm{open_or_create, "Boost", 1024};
  int *i = managed_shm.construct<int>("Integer")(99);
  std::cout << *i << '\n';
  std::pair<int*, std::size_t> p = managed_shm.find<int>("Integer");
  if (p.first)
    std::cout << *p.first << '\n';
}

in reply to:  1 comment:2 by kaparis.dimitri@…, 7 years ago

Replying to kaparis.dimitri@…:

The same problem affects example 33.10 of the chapter on Managed Shared Memory of "The Boost C++ Libraries" book (http://theboostcpplibraries.com/boost.interprocess-managed-shared-memory):

Sorry, copied wrong example. This is the correct one:

#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/containers/string.hpp>
#include <iostream>

using namespace boost::interprocess;

int main()
{
  shared_memory_object::remove("Boost");
  managed_shared_memory managed_shm{open_or_create, "Boost", 1024};
  typedef allocator<char,
    managed_shared_memory::segment_manager> CharAllocator;
  typedef basic_string<char, std::char_traits<char>, CharAllocator> string;
  string *s = managed_shm.find_or_construct<string>("String")("Hello!",
    managed_shm.get_segment_manager());
  s->insert(5, ", world");
  std::cout << *s << '\n';
}

comment:3 by kaparis.dimitri@…, 7 years ago

Summary: boost::interprocess::basic_string instantiation brokenboost::interprocess::basic_string instantiation broken (wrong report - please close ticket!)

Apologies, the error is on my side - it seems I have mixed up some older version headers.

Please disregard and close ticket.

comment:4 by Ion Gaztañaga, 7 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.