Merge remote-tracking branch 'origin/develop'

This commit is contained in:
Daniel James
2015-01-24 14:37:21 +00:00
7 changed files with 78 additions and 5 deletions

View File

@@ -317,7 +317,7 @@ separately allocated reference counter).
}; };
template< typename Pointer, template< typename Pointer,
class Allocator = boost::none_t, class Allocator = void,
factory_alloc_propagation AllocProp = factory_alloc_propagation AllocProp =
factory_alloc_for_pointee_and_deleter > factory_alloc_for_pointee_and_deleter >
class factory; class factory;
@@ -351,6 +351,19 @@ maximum arity. It defaults to 10.
[endsect] [endsect]
[section Changes]
[heading Boost 1.58.0]
In order to remove the dependency on Boost.Optional, the default parameter
for allocators has been changed from `boost::none_t` to `void`.
If you have code that has stopped working because it uses `boost::none_t`,
a quick fix is to define `BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T`, which will
restore support, but this will be removed in a future release.
It should be be relatively easy to fix this properly.
[endsect]
[section Acknowledgements] [section Acknowledgements]
Eric Niebler requested a function to invoke a type's constructor (with the Eric Niebler requested a function to invoke a type's constructor (with the

View File

@@ -14,5 +14,9 @@ test-suite functional/factory
[ run value_factory.cpp ] [ run value_factory.cpp ]
[ run factory.cpp ] [ run factory.cpp ]
[ run factory_with_allocator.cpp ] [ run factory_with_allocator.cpp ]
[ compile-fail factory_with_none_t.cpp ]
[ run factory.cpp : : : <define>BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T : none_t_factory ]
[ run factory_with_allocator.cpp : : : <define>BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T : none_t_factory_with_allocator ]
[ run factory_with_none_t.cpp : : : <define>BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T : none_t_factory_with_none_t ]
; ;

View File

@@ -0,0 +1,36 @@
/*=============================================================================
Copyright (c) 2007 Tobias Schwinger
Use modification and distribution are subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
==============================================================================*/
#include <boost/functional/factory.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <memory>
class sum
{
int val_sum;
public:
sum(int a, int b) : val_sum(a + b) { }
operator int() const { return this->val_sum; }
};
int main()
{
int one = 1, two = 2;
{
sum* instance( boost::factory< sum*, boost::none_t >()(one,two) );
BOOST_TEST(*instance == 3);
}
{
std::auto_ptr<sum> instance(
boost::factory< std::auto_ptr<sum>, boost::none_t >()(one,two) );
BOOST_TEST(*instance == 3);
}
return boost::report_errors();
}

View File

@@ -174,4 +174,9 @@
* Ongoing work on improving `hash_combine`. This changes the combine function * Ongoing work on improving `hash_combine`. This changes the combine function
which was previously defined in the reference documentation. which was previously defined in the reference documentation.
[h2 Boost 1.58.0]
* Fixed strict aliasing violation
([@https://github.com/boostorg/functional/pull/3 GitHub #3]).
[endsect] [endsect]

View File

@@ -15,11 +15,14 @@
# include <new> # include <new>
# include <boost/pointee.hpp> # include <boost/pointee.hpp>
# include <boost/none_t.hpp>
# include <boost/get_pointer.hpp> # include <boost/get_pointer.hpp>
# include <boost/non_type.hpp> # include <boost/non_type.hpp>
# include <boost/type_traits/remove_cv.hpp> # include <boost/type_traits/remove_cv.hpp>
# if defined(BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T)
# include <boost/none_t.hpp>
# endif
# ifndef BOOST_FUNCTIONAL_FACTORY_MAX_ARITY # ifndef BOOST_FUNCTIONAL_FACTORY_MAX_ARITY
# define BOOST_FUNCTIONAL_FACTORY_MAX_ARITY 10 # define BOOST_FUNCTIONAL_FACTORY_MAX_ARITY 10
# elif BOOST_FUNCTIONAL_FACTORY_MAX_ARITY < 3 # elif BOOST_FUNCTIONAL_FACTORY_MAX_ARITY < 3
@@ -35,14 +38,20 @@ namespace boost
factory_passes_alloc_to_smart_pointer factory_passes_alloc_to_smart_pointer
}; };
#if defined(BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T)
template< typename Pointer, class Allocator = boost::none_t, template< typename Pointer, class Allocator = boost::none_t,
factory_alloc_propagation AP = factory_alloc_for_pointee_and_deleter > factory_alloc_propagation AP = factory_alloc_for_pointee_and_deleter >
class factory; class factory;
#else
template< typename Pointer, class Allocator = void,
factory_alloc_propagation AP = factory_alloc_for_pointee_and_deleter >
class factory;
#endif
//----- ---- --- -- - - - - //----- ---- --- -- - - - -
template< typename Pointer, factory_alloc_propagation AP > template< typename Pointer, factory_alloc_propagation AP >
class factory<Pointer, boost::none_t, AP> class factory<Pointer, void, AP>
{ {
public: public:
typedef typename boost::remove_cv<Pointer>::type result_type; typedef typename boost::remove_cv<Pointer>::type result_type;
@@ -56,6 +65,13 @@ namespace boost
# include BOOST_PP_ITERATE() # include BOOST_PP_ITERATE()
}; };
#if defined(BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T)
template< typename Pointer, factory_alloc_propagation AP >
class factory<Pointer, boost::none_t, AP>
: public factory<Pointer, void, AP>
{};
#endif
template< class Pointer, class Allocator, factory_alloc_propagation AP > template< class Pointer, class Allocator, factory_alloc_propagation AP >
class factory class factory
: private Allocator::template rebind< typename boost::pointee< : private Allocator::template rebind< typename boost::pointee<

View File

@@ -68,7 +68,7 @@ namespace boost
std::size_t seed = 0; std::size_t seed = 0;
if (length >= sizeof(std::size_t)) { if (length >= sizeof(std::size_t)) {
seed = *(std::size_t*) ptr; std::memcpy(&seed, ptr, sizeof(std::size_t));
length -= sizeof(std::size_t); length -= sizeof(std::size_t);
ptr += sizeof(std::size_t); ptr += sizeof(std::size_t);

View File

@@ -15,7 +15,6 @@
# include <new> # include <new>
# include <boost/pointee.hpp> # include <boost/pointee.hpp>
# include <boost/none_t.hpp>
# include <boost/get_pointer.hpp> # include <boost/get_pointer.hpp>
# include <boost/non_type.hpp> # include <boost/non_type.hpp>
# include <boost/type_traits/remove_cv.hpp> # include <boost/type_traits/remove_cv.hpp>