diff --git a/factory/doc/factory.qbk b/factory/doc/factory.qbk index 7aa3faf..3b4e99b 100644 --- a/factory/doc/factory.qbk +++ b/factory/doc/factory.qbk @@ -317,7 +317,7 @@ separately allocated reference counter). }; template< typename Pointer, - class Allocator = boost::none_t, + class Allocator = void, factory_alloc_propagation AllocProp = factory_alloc_for_pointee_and_deleter > class factory; @@ -351,6 +351,19 @@ maximum arity. It defaults to 10. [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] Eric Niebler requested a function to invoke a type's constructor (with the diff --git a/factory/test/Jamfile b/factory/test/Jamfile index 6c4f6eb..fe5041f 100644 --- a/factory/test/Jamfile +++ b/factory/test/Jamfile @@ -14,5 +14,9 @@ test-suite functional/factory [ run value_factory.cpp ] [ run factory.cpp ] [ run factory_with_allocator.cpp ] + [ compile-fail factory_with_none_t.cpp ] + [ run factory.cpp : : : BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T : none_t_factory ] + [ run factory_with_allocator.cpp : : : BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T : none_t_factory_with_allocator ] + [ run factory_with_none_t.cpp : : : BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T : none_t_factory_with_none_t ] ; diff --git a/factory/test/factory_with_none_t.cpp b/factory/test/factory_with_none_t.cpp new file mode 100644 index 0000000..cf203f0 --- /dev/null +++ b/factory/test/factory_with_none_t.cpp @@ -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 +#include + +#include + +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 instance( + boost::factory< std::auto_ptr, boost::none_t >()(one,two) ); + BOOST_TEST(*instance == 3); + } + return boost::report_errors(); +} diff --git a/hash/doc/changes.qbk b/hash/doc/changes.qbk index aadeb97..f7ab411 100644 --- a/hash/doc/changes.qbk +++ b/hash/doc/changes.qbk @@ -174,4 +174,9 @@ * Ongoing work on improving `hash_combine`. This changes the combine function 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] diff --git a/include/boost/functional/factory.hpp b/include/boost/functional/factory.hpp index 4aa4267..67fee71 100644 --- a/include/boost/functional/factory.hpp +++ b/include/boost/functional/factory.hpp @@ -15,11 +15,14 @@ # include # include -# include # include # include # include +# if defined(BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T) +# include +# endif + # ifndef BOOST_FUNCTIONAL_FACTORY_MAX_ARITY # define BOOST_FUNCTIONAL_FACTORY_MAX_ARITY 10 # elif BOOST_FUNCTIONAL_FACTORY_MAX_ARITY < 3 @@ -35,14 +38,20 @@ namespace boost factory_passes_alloc_to_smart_pointer }; +#if defined(BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T) template< typename Pointer, class Allocator = boost::none_t, factory_alloc_propagation AP = factory_alloc_for_pointee_and_deleter > 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 > - class factory + class factory { public: typedef typename boost::remove_cv::type result_type; @@ -56,6 +65,13 @@ namespace boost # include BOOST_PP_ITERATE() }; +#if defined(BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T) + template< typename Pointer, factory_alloc_propagation AP > + class factory + : public factory + {}; +#endif + template< class Pointer, class Allocator, factory_alloc_propagation AP > class factory : private Allocator::template rebind< typename boost::pointee< diff --git a/include/boost/functional/hash/detail/hash_float.hpp b/include/boost/functional/hash/detail/hash_float.hpp index ee0ee87..eb9264f 100644 --- a/include/boost/functional/hash/detail/hash_float.hpp +++ b/include/boost/functional/hash/detail/hash_float.hpp @@ -68,7 +68,7 @@ namespace boost std::size_t seed = 0; if (length >= sizeof(std::size_t)) { - seed = *(std::size_t*) ptr; + std::memcpy(&seed, ptr, sizeof(std::size_t)); length -= sizeof(std::size_t); ptr += sizeof(std::size_t); diff --git a/include/boost/functional/value_factory.hpp b/include/boost/functional/value_factory.hpp index 6047908..ba94c2a 100644 --- a/include/boost/functional/value_factory.hpp +++ b/include/boost/functional/value_factory.hpp @@ -15,7 +15,6 @@ # include # include -# include # include # include # include