[container][memory] Request to move allocator_arg_t and uses_allocator to a memory related file.

Hi, I want to add Allocators to the packaged_task and promise class of Boost.Thread template <class Allocator> promise(allocator_arg_t, const Allocator& a); template <class F, class Allocator> explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f); I see that Boost.Container has already defined in namespace boost::container and in file boost/container/scoped_allocator.hpp the following struct allocator_arg_t { }; constexpr allocator_arg_t allocator_arg = allocator_arg_t(); template <class T, class Alloc> struct uses_allocator; I would like to shared these to all the Boost libraries. I don't think it is a good idea to make Boost.Thread depend on Boost.Container just for this. Could these declarations be included in a specific file? These declaration are included in <memory> in the C++11. What would be the best library to contain these declarations? What about a new boost/memory.hpp file? What about moving them to the boost or boost::memory namespace? Best, Vicente

El 31/03/2012 11:03, Vicente J. Botet Escriba escribió:
I see that Boost.Container has already defined in namespace boost::container and in file boost/container/scoped_allocator.hpp the following
struct allocator_arg_t { }; constexpr allocator_arg_t allocator_arg = allocator_arg_t();
template <class T, class Alloc> struct uses_allocator;
There is no constexpr in Boost.Container code. Current trunk code includes an experimental implementation of scoped_allocator, for C++03 and C++11 compilers.
I would like to shared these to all the Boost libraries. I don't think it is a good idea to make Boost.Thread depend on Boost.Container just for this. Could these declarations be included in a specific file? These declaration are included in <memory> in the C++11. What would be the best library to contain these declarations?
I don't think Boost.thread should depend on Boost.Container, that's why I've added those classes to boost::container namespace, avoiding any boost:: namespace pollution. The idea is also to define them as std:: typedefs so that a user with a C++11 conforming standard library does not need to add boost::container::xxx overloads. And user C++03 code using boost::xxx types is standard conforming when compiled with C++11 compilers.
What about a new boost/memory.hpp file? What about moving them to the boost or boost::memory namespace?
I think it's a good idea. But we should just typedef them to std:: if the standard library provides those types. I think GCC 4.7 libstdc++ and libc++ already support scoped allocators. Best, Ion

Le 31/03/12 12:04, Ion Gaztañaga a écrit :
El 31/03/2012 11:03, Vicente J. Botet Escriba escribió:
I see that Boost.Container has already defined in namespace boost::container and in file boost/container/scoped_allocator.hpp the following
struct allocator_arg_t { }; constexpr allocator_arg_t allocator_arg = allocator_arg_t();
template <class T, class Alloc> struct uses_allocator;
There is no constexpr in Boost.Container code. Current trunk code includes an experimental implementation of scoped_allocator, for C++03 and C++11 compilers.
I would like to shared these to all the Boost libraries. I don't think it is a good idea to make Boost.Thread depend on Boost.Container just for this. Could these declarations be included in a specific file? These declaration are included in <memory> in the C++11. What would be the best library to contain these declarations?
I don't think Boost.thread should depend on Boost.Container, that's why I've added those classes to boost::container namespace, avoiding any boost:: namespace pollution. The idea is also to define them as std:: typedefs so that a user with a C++11 conforming standard library does not need to add boost::container::xxx overloads. And user C++03 code using boost::xxx types is standard conforming when compiled with C++11 compilers. Have you a plan to add these definitions at the boost level?
What about a new boost/memory.hpp file? What about moving them to the boost or boost::memory namespace?
I think it's a good idea. But we should just typedef them to std:: if the standard library provides those types. I think GCC 4.7 libstdc++ and libc++ already support scoped allocators.
Let me know if I can help on this. Best, Vicente

Le 31/03/12 14:48, Vicente J. Botet Escriba a écrit :
Le 31/03/12 12:04, Ion Gaztañaga a écrit :
El 31/03/2012 11:03, Vicente J. Botet Escriba escribió:
I see that Boost.Container has already defined in namespace boost::container and in file boost/container/scoped_allocator.hpp the following
struct allocator_arg_t { }; constexpr allocator_arg_t allocator_arg = allocator_arg_t();
template <class T, class Alloc> struct uses_allocator;
There is no constexpr in Boost.Container code. Current trunk code includes an experimental implementation of scoped_allocator, for C++03 and C++11 compilers.
I would like to shared these to all the Boost libraries. I don't think it is a good idea to make Boost.Thread depend on Boost.Container just for this. Could these declarations be included in a specific file? These declaration are included in <memory> in the C++11. What would be the best library to contain these declarations?
I don't think Boost.thread should depend on Boost.Container, that's why I've added those classes to boost::container namespace, avoiding any boost:: namespace pollution. The idea is also to define them as std:: typedefs so that a user with a C++11 conforming standard library does not need to add boost::container::xxx overloads. And user C++03 code using boost::xxx types is standard conforming when compiled with C++11 compilers. Have you a plan to add these definitions at the boost level? BTW,
I'm getting ../../../boost/container/allocator_traits.hpp:170:105: error: type name requires a specifier or qualifier template <typename T> using rebind_alloc = boost::intrusive::detail::type_rebinder<Alloc, T>::type; when compiling with clang 3.0 C++11 Adding typename in #if !defined(BOOST_NO_TEMPLATE_ALIASES) //C++11 template <typename T> using rebind_alloc = typename boost::intrusive::detail::type_rebinder<Alloc, T>::type; Solve the issue. I have checked it with clang 3.0 (c++11) and gcc-4.7.0 (c++11). Could you try to fix this? Thanks, Vicente

El 31/03/2012 15:47, Vicente J. Botet Escriba escribió:
../../../boost/container/allocator_traits.hpp:170:105: error: type name requires a specifier or qualifier template <typename T> using rebind_alloc = boost::intrusive::detail::type_rebinder<Alloc, T>::type;
when compiling with clang 3.0 C++11
Adding typename in
#if !defined(BOOST_NO_TEMPLATE_ALIASES) //C++11 template <typename T> using rebind_alloc = typename boost::intrusive::detail::type_rebinder<Alloc, T>::type;
Solve the issue.
I have checked it with clang 3.0 (c++11) and gcc-4.7.0 (c++11).
Could you try to fix this?
Done, thanks. Ion

El 31/03/2012 14:48, Vicente J. Botet Escriba escribió:
Have you a plan to add these definitions at the boost level?
I don't think we should modify anything at boost level before reaching consensus on the mailing as it might potentially affect many users. <memory> includes scoped_allocator_adaptor, should we add it? boost::container::scoped_allocator_adaptor is dependent on many boost.container and boost.intrusive, so it does not seem a good idea (maybe we are missing a boost.allocator library). It also includes smart pointers, uninitialized_xxx functions, allocator_traits... Another option is to define uses_allocator.hpp, allocator_arg.hpp, etc. We'll have the same problem with many C++11 features to be backported to C++03 compilers so a general rule should be discussed in the mailing list. Best, Ion
participants (2)
-
Ion Gaztañaga
-
Vicente J. Botet Escriba