|
Boost Users : |
Subject: [Boost-users] Boost::Interprocess - using variadic template args with managed_shared_memory::construct()
From: james (dirtydroog_at_[hidden])
Date: 2014-04-28 06:49:39
Hi,
I'm trying to write a wrapper over some of boost::interprocess and I want
to have a function like this:
template <typename T, typename... Args>
T* Wrapper::createStruct(const std::string& name, Args&&... args)
{
return m_shm->construct<T>(name.c_str())(std::forward<Args>(args)...);
}
This fails to compile as it seems boost::interprocess uses its own varargs
scheme when I try to create
the following struct in the SHM through this wrapper function:
struct Custom
{
Custom(int a, int b)
: m_a(a),
m_b(b)
{
}
int a;
int b;
}
int main()
{
...
Custom* c = shm->createStruct("Custom", 1, 2);
}
The error message:
/usr/include/boost/interprocess/detail/named_proxy.hpp:79:7: error: no
matching function for call to
âtest_sharedmemory::sharedmemory_custom::test_method()::Custom::Custom()â
{ new((void*)mem)T(boost::forward<Args>(get<IdxPack>(args_))...); }
^
/usr/include/boost/interprocess/detail/named_proxy.hpp:79:7: note:
candidates are:
/home/james/dev/infinityplus/test/common/shm/sharedmemory/main.cpp:136:7:
note:
test_sharedmemory::sharedmemory_custom::test_method()::Custom::Custom(int,
int)
Custom(int one, int two)
^
/home/james/dev/infinityplus/test/common/shm/sharedmemory/main.cpp:136:7:
note: candidate expects 2 arguments, 0 provided
Is there any way I can get this to work? I'd rather my wrapper's interface
used std only.
boost 1.55
c++11
g++ 4.8.2
TIA,
James
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net