Squashed 'third_party/boostorg/functional/' content from commit 7516442

Change-Id: I0e437294bc2af9d32de5022be6ac788cc67244d1
git-subtree-dir: third_party/boostorg/functional
git-subtree-split: 7516442815900430cc9c4a6190354e11bcbe72dd
diff --git a/factory/doc/Jamfile b/factory/doc/Jamfile
new file mode 100644
index 0000000..1653336
--- /dev/null
+++ b/factory/doc/Jamfile
@@ -0,0 +1,20 @@
+
+# (C) Copyright Tobias Schwinger
+#
+# Use modification and distribution are subject to the boost Software License,
+# Version 1.0. (See http:/\/www.boost.org/LICENSE_1_0.txt).
+
+using quickbook ;
+
+xml factory : factory.qbk ;
+boostbook standalone : factory
+  :
+        <xsl:param>boost.root=../../../../..
+        <xsl:param>boost.libraries=../../../../libraries.htm
+        <xsl:param>chunk.section.depth=0
+        <xsl:param>chunk.first.sections=0
+        <xsl:param>generate.section.toc.level=2
+        <xsl:param>toc.max.depth=1
+  ;
+
+
diff --git a/factory/doc/factory.qbk b/factory/doc/factory.qbk
new file mode 100644
index 0000000..3b4e99b
--- /dev/null
+++ b/factory/doc/factory.qbk
@@ -0,0 +1,399 @@
+[library Boost.Functional/Factory
+  [quickbook 1.3]
+  [version 1.0]
+  [authors [Schwinger, Tobias]]
+  [copyright 2007 2008 Tobias Schwinger]
+  [license
+        Distributed under 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])
+  ]
+  [purpose Function object templates for object creation.]
+  [category higher-order]
+  [category generic]
+  [last-revision $Date: 2008/11/01 21:44:52 $]
+]
+
+[def __boost_bind__ [@http://www.boost.org/libs/bind/bind.html Boost.Bind]]
+[def __boost__bind__ [@http://www.boost.org/libs/bind/bind.html `boost::bind`]]
+
+[def __boost__forward_adapter__ [@http://www.boost.org/libs/functional/forward/doc/index.html `boost::forward_adapter`]]
+[def __fusion_functional_adapters__ [@http://www.boost.org/libs/fusion/doc/html/functional.html Fusion Functional Adapters]]
+
+[def __boost_function__ [@http://www.boost.org/doc/html/function.html Boost.Function]]
+[def __boost__function__ [@http://www.boost.org/doc/html/function.html `boost::function`]]
+
+[def __smart_pointer__ [@http://www.boost.org/libs/smart_ptr/index.html Smart Pointer]]
+[def __smart_pointers__ [@http://www.boost.org/libs/smart_ptr/index.html Smart Pointers]]
+[def __boost__shared_ptr__ [@http://www.boost.org/libs/smart_ptr/shared_ptr.htm `boost::shared_ptr`]]
+
+[def __std__map__ [@http://www.sgi.com/tech/stl/map.html `std::map`]]
+[def __std__string__ [@http://www.sgi.com/tech/stl/string.html `std::string`]]
+[def __allocator__ [@http://www.sgi.com/tech/stl/concepts/allocator.html Allocator]]
+[def __std_allocator__ [@http://www.sgi.com/tech/stl/concepts/allocator.html Allocator]]
+[def __std_allocators__ [@http://www.sgi.com/tech/stl/concepts/allocator.html Allocators]]
+
+[def __boost__ptr_map__ [@http://www.boost.org/libs/ptr_container/doc/ptr_map.html `boost::ptr_map`]]
+
+[def __boost__factory__ `boost::factory`]
+[def __boost__value_factory__ `boost::value_factory`]
+
+[def __factory__ `factory`]
+[def __value_factory__ `value_factory`]
+
+
+[section Brief Description]
+
+The template __boost__factory__ lets you encapsulate a `new` expression
+as a function object, __boost__value_factory__ encapsulates a constructor
+invocation without `new`.
+
+    __boost__factory__<T*>()(arg1,arg2,arg3) 
+    // same as new T(arg1,arg2,arg3)
+
+    __boost__value_factory__<T>()(arg1,arg2,arg3)
+    // same as T(arg1,arg2,arg3)
+
+For technical reasons the arguments to the function objects have to be
+LValues. A factory that also accepts RValues can be composed using the
+__boost__forward_adapter__ or __boost__bind__.
+
+[endsect]
+
+[section Background]
+
+In traditional Object Oriented Programming a Factory is an object implementing
+an interface of one or more methods that construct objects conforming to known
+interfaces.
+
+    // assuming a_concrete_class and another_concrete_class are derived
+    // from an_abstract_class
+
+    class a_factory
+    {
+      public:
+        virtual an_abstract_class* create() const = 0;
+        virtual ~a_factory() { }
+    };
+
+    class a_concrete_factory : public a_factory
+    {
+      public:
+        virtual an_abstract_class* create() const
+        {
+            return new a_concrete_class();
+        }
+    };
+
+    class another_concrete_factory : public a_factory
+    {
+      public:
+        virtual an_abstract_class* create() const
+        {
+            return new another_concrete_class();
+        }
+    };
+
+    // [...]
+
+    int main()
+    {
+        __boost__ptr_map__<__std__string__,a_factory> factories;
+
+        // [...]
+
+        factories.insert("a_name",std::auto_ptr<a_factory>(
+            new a_concrete_factory));
+        factories.insert("another_name",std::auto_ptr<a_factory>(
+            new another_concrete_factory));
+
+        // [...]
+
+        std::auto_ptr<an_abstract_class> x(factories.at(some_name).create());
+
+        // [...]
+    }
+
+This approach has several drawbacks. The most obvious one is that there is
+lots of boilerplate code. In other words there is too much code to express
+a rather simple intention. We could use templates to get rid of some of it
+but the approach remains inflexible: 
+
+* We may want a factory that takes some arguments that are forwarded to
+  the constructor,
+* we will probably want to use smart pointers,
+* we may want several member functions to create different kinds of
+  objects,
+* we might not necessarily need a polymorphic base class for the objects,
+* as we will see, we do not need a factory base class at all, 
+* we might want to just call the constructor - without `new` to create
+  an object on the stack, and
+* finally we might want to use customized memory management.
+
+Experience has shown that using function objects and generic Boost components
+for their composition, Design Patterns that describe callback mechanisms
+(typically requiring a high percentage of boilerplate code with pure Object
+Oriented methodology) become implementable with just few code lines and without
+extra classes. 
+
+Factories are callback mechanisms for constructors, so we provide two class
+templates, __boost__value_factory__ and __boost__factory__, that encapsulate
+object construction via direct application of the constructor and the `new`
+operator, respectively. 
+
+We let the function objects forward their arguments to the construction
+expressions they encapsulate. Over this __boost__factory__ optionally allows
+the use of smart pointers and __std_allocators__.
+
+Compile-time polymorphism can be used where appropriate,
+
+    template< class T >
+    void do_something()
+    {
+        // [...]
+        T x = T(a,b);
+
+        // for conceptually similar objects x we neither need virtual
+        // functions nor a common base class in this context.
+        // [...]
+    }
+
+Now, to allow inhomogeneous signatures for the constructors of the types passed
+in for `T` we can use __value_factory__ and __boost__bind__ to normalize between
+them. 
+
+    template< class ValueFactory > 
+    void do_something(ValueFactory make_obj = ValueFactory())
+    {
+        // [...]
+        typename ValueFactory::result_type x = make_obj(a,b);
+
+        // for conceptually similar objects x we neither need virtual
+        // functions nor a common base class in this context.
+        // [...]
+    }
+
+    int main()
+    {
+        // [...]
+
+        do_something(__boost__value_factory__<X>());
+        do_something(boost::bind(__boost__value_factory__<Y>(),_1,5,_2));
+        // construct X(a,b) and Y(a,5,b), respectively.
+
+        // [...]
+    }
+
+Maybe we want our objects to outlive the function's scope, in this case we
+have to use dynamic allocation;
+
+    template< class Factory >
+    whatever do_something(Factory new_obj = Factory())
+    {
+        typename Factory::result_type ptr = new_obj(a,b);
+
+        // again, no common base class or virtual functions needed,
+        // we could enforce a polymorphic base by writing e.g.
+        //    boost::shared_ptr<base>
+        // instead of
+        //    typename Factory::result_type
+        // above.
+        // Note that we are also free to have the type erasure happen 
+        // somewhere else (e.g. in the constructor of this function's
+        // result type).
+
+        // [...]
+    }
+
+    // [... call do_something like above but with __factory__ instead
+    // of __value_factory__]
+
+Although we might have created polymorphic objects in the previous example,
+we have used compile time polymorphism for the factory. If we want to erase
+the type of the factory and thus allow polymorphism at run time, we can
+use __boost_function__ to do so. The first example can be rewritten as 
+follows.
+
+    typedef boost::function< an_abstract_class*() > a_factory;
+
+    // [...]
+
+    int main()
+    {
+        __std__map__<__std__string__,a_factory> factories;
+
+        // [...]
+
+        factories["a_name"] = __boost__factory__<a_concrete_class*>();
+        factories["another_name"] = 
+            __boost__factory__<another_concrete_class*>();
+
+        // [...]
+    } 
+
+Of course we can just as easy create factories that take arguments and/or
+return __smart_pointers__.
+
+[endsect]
+
+
+[section:reference Reference]
+
+
+[section value_factory]
+
+[heading Description]
+
+Function object template that invokes the constructor of the type `T`.
+
+[heading Header]
+    #include <boost/functional/value_factory.hpp>
+
+[heading Synopsis]
+
+    namespace boost
+    {
+        template< typename T >
+        class value_factory;
+    }
+
+[variablelist Notation
+    [[`T`]         [an arbitrary type with at least one public constructor]]
+    [[`a0`...`aN`] [argument LValues to a constructor of `T`]]
+    [[`F`]         [the type `value_factory<F>`]]
+    [[`f`]         [an instance object of `F`]]
+]
+
+[heading Expression Semantics]
+
+[table
+    [[Expression]       [Semantics]]
+    [[`F()`]            [creates an object of type `F`.]]
+    [[`F(f)`]           [creates an object of type `F`.]]
+    [[`f(a0`...`aN)`]   [returns `T(a0`...`aN)`.]]
+    [[`F::result_type`] [is the type `T`.]]
+]
+
+[heading Limits]
+
+The macro BOOST_FUNCTIONAL_VALUE_FACTORY_MAX_ARITY can be defined to set the
+maximum arity. It defaults to 10.
+
+[endsect]
+
+
+[section factory]
+
+[heading Description]
+
+Function object template that dynamically constructs a pointee object for
+the type of pointer given as template argument. Smart pointers may be used
+for the template argument, given that `boost::pointee<Pointer>::type` yields
+the pointee type.
+
+If an __allocator__ is given, it is used for memory allocation and the 
+placement form of the `new` operator is used to construct the object.
+A function object that calls the destructor and deallocates the memory
+with a copy of the Allocator is used for the second constructor argument
+of `Pointer` (thus it must be a __smart_pointer__ that provides a suitable 
+constructor, such as __boost__shared_ptr__).
+
+If a third template argument is `factory_passes_alloc_to_smart_pointer`,
+the allocator itself is used for the third constructor argument of `Pointer`
+(__boost__shared_ptr__ then uses the allocator to manage the memory of its
+separately allocated reference counter).
+
+[heading Header]
+    #include <boost/functional/factory.hpp>
+
+[heading Synopsis]
+
+    namespace boost
+    {
+        enum factory_alloc_propagation
+        {
+            factory_alloc_for_pointee_and_deleter,
+            factory_passes_alloc_to_smart_pointer
+        };
+
+        template< typename Pointer, 
+            class Allocator = void,
+            factory_alloc_propagation AllocProp =
+                factory_alloc_for_pointee_and_deleter >
+        class factory;
+    }
+
+[variablelist Notation
+    [[`T`]         [an arbitrary type with at least one public constructor]]
+    [[`P`]         [pointer or smart pointer to `T`]]
+    [[`a0`...`aN`] [argument LValues to a constructor of `T`]]
+    [[`F`]         [the type `factory<P>`]]
+    [[`f`]         [an instance object of `F`]]
+]
+
+[heading Expression Semantics]
+
+[table
+    [[Expression]       [Semantics]]
+    [[`F()`]            [creates an object of type `F`.]]
+    [[`F(f)`]           [creates an object of type `F`.]]
+    [[`f(a0`...`aN)`]   [dynamically creates an object of type `T` using 
+        `a0`...`aN` as arguments for the constructor invocation.]]
+    [[`F::result_type`] [is the type `P` with top-level cv-qualifiers removed.]]
+]
+
+[heading Limits]
+
+The macro BOOST_FUNCTIONAL_FACTORY_MAX_ARITY can be defined to set the
+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]
+
+Eric Niebler requested a function to invoke a type's constructor (with the 
+arguments supplied as a Tuple) as a Fusion feature. These Factory utilities are
+a factored-out generalization of this idea.
+
+Dave Abrahams suggested Smart Pointer support for exception safety, providing
+useful hints for the implementation.
+
+Joel de Guzman's documentation style was copied from Fusion.
+
+Further, I want to thank Peter Dimov for sharing his insights on language
+details and their evolution.
+
+[endsect]
+
+[section References]
+
+# [@http://en.wikipedia.org/wiki/Design_Patterns Design Patterns],
+  Gamma et al. - Addison Wesley Publishing, 1995
+
+# [@http://www.sgi.com/tech/stl/ Standard Template Library Programmer's Guide], 
+  Hewlett-Packard Company, 1994
+
+# [@http://www.boost.org/libs/bind/bind.html Boost.Bind], 
+  Peter Dimov, 2001-2005
+
+# [@http://www.boost.org/doc/html/function.html Boost.Function],
+  Douglas Gregor, 2001-2004
+
+[endsect]
+
+
diff --git a/factory/doc/html/index.html b/factory/doc/html/index.html
new file mode 100644
index 0000000..f0a0d5e
--- /dev/null
+++ b/factory/doc/html/index.html
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+  <head>
+  <!-- Copyright (C) 2002 Douglas Gregor <doug.gregor -at- gmail.com>
+
+      Distributed under 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) -->
+    <title>Redirect to generated documentation</title>
+    <meta http-equiv="refresh" content="0; URL=http://www.boost.org/doc/libs/master/libs/functional/factory/doc/html/">
+  </head>
+  <body>
+    Automatic redirection failed, please go to
+    <a href="http://www.boost.org/doc/libs/master/libs/functional/factory/doc/html/">http://www.boost.org/doc/libs/master/libs/functional/factory/doc/html/</a>
+  </body>
+</html>
diff --git a/factory/index.html b/factory/index.html
new file mode 100644
index 0000000..1803029
--- /dev/null
+++ b/factory/index.html
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+  <head>
+    <meta http-equiv="refresh" content="0; URL=doc/html/index.html">
+  </head>
+  <body>
+    Automatic redirection failed, click this 
+    <a href="doc/html/index.html">link</a> &nbsp;<hr>
+    <p>© Copyright Tobias Schwinger, 2009</p>
+    <p>Distributed under the Boost Software License, Version 1.0. (See 
+    accompanying file <a href="../../../LICENSE_1_0.txt">
+    LICENSE_1_0.txt</a> or copy at
+    <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
+  </body>
+</html>
diff --git a/factory/test/Jamfile b/factory/test/Jamfile
new file mode 100644
index 0000000..c4a06af
--- /dev/null
+++ b/factory/test/Jamfile
@@ -0,0 +1,24 @@
+
+# (C) Copyright Tobias Schwinger
+#
+# Use modification and distribution are subject to the boost Software License,
+# Version 1.0. (See http:/\/www.boost.org/LICENSE_1_0.txt).
+
+import testing ;
+
+project factory-tests
+    ;
+
+test-suite functional/factory
+    :
+      [ run value_factory.cpp ]
+      [ run factory.cpp ]
+      [ run factory_with_allocator.cpp ]
+      [ run factory_with_std_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_std_allocator.cpp : : : <define>BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T : none_t_factory_with_std_allocator ]
+      [ run factory_with_none_t.cpp : : : <define>BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T : none_t_factory_with_none_t ]
+    ;
+
diff --git a/factory/test/factory.cpp b/factory/test/factory.cpp
new file mode 100644
index 0000000..ef895cf
--- /dev/null
+++ b/factory/test/factory.cpp
@@ -0,0 +1,53 @@
+/*=============================================================================
+    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/core/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; }
+};
+
+// Suppress warnings about std::auto_ptr.
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
+int main()
+{
+    int one = 1, two = 2;
+    {
+      sum* instance( boost::factory< sum* >()(one,two) );
+      BOOST_TEST(*instance == 3);
+    }
+#if !defined(BOOST_NO_AUTO_PTR)
+    {
+      std::auto_ptr<sum> instance( boost::factory< std::auto_ptr<sum> >()(one,two) );
+      BOOST_TEST(*instance == 3);
+    }
+#endif
+#if !defined(BOOST_NO_CXX11_SMART_PTR)
+    {
+      std::unique_ptr<sum> instance( boost::factory< std::unique_ptr<sum> >()(one,two) );
+      BOOST_TEST(*instance == 3);
+    }
+#endif
+    return boost::report_errors();
+}
+
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
diff --git a/factory/test/factory_with_allocator.cpp b/factory/test/factory_with_allocator.cpp
new file mode 100644
index 0000000..c1eef65
--- /dev/null
+++ b/factory/test/factory_with_allocator.cpp
@@ -0,0 +1,84 @@
+/*=============================================================================
+    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/core/lightweight_test.hpp>
+
+#include <cstddef>
+#include <memory>
+#include <boost/shared_ptr.hpp>
+
+#ifdef BOOST_MSVC
+// none of the deprecated members of std::allocate are used here
+# pragma warning(disable:4996) // Various members of std::allocator are deprecated in C++17
+#endif
+
+using std::size_t;
+
+class sum 
+{
+    int val_sum;
+  public:
+    sum(int a, int b) : val_sum(a + b) { }
+
+    operator int() const { return this->val_sum; }
+};
+
+template< typename T >
+class counting_allocator : public std::allocator<T>
+{
+  public:
+    counting_allocator()
+    { }
+
+    template< typename OtherT >
+    struct rebind { typedef counting_allocator<OtherT> other; };
+
+    template< typename OtherT >
+    counting_allocator(counting_allocator<OtherT> const& that)
+    { }
+
+    static size_t n_allocated;
+    T* allocate(size_t n, void const* hint = 0l)
+    {
+        n_allocated += 1;
+        return std::allocator<T>::allocate(n,hint);
+    }
+
+    static size_t n_deallocated;
+    void deallocate(T* ptr, size_t n)
+    {
+        n_deallocated += 1;
+        return std::allocator<T>::deallocate(ptr,n);
+    }
+};
+template< typename T > size_t counting_allocator<T>::n_allocated = 0;
+template< typename T > size_t counting_allocator<T>::n_deallocated = 0;
+
+int main()
+{
+    int one = 1, two = 2;
+    {
+      boost::shared_ptr<sum> instance(
+          boost::factory< boost::shared_ptr<sum>, counting_allocator<void>, 
+              boost::factory_alloc_for_pointee_and_deleter >()(one,two) );
+      BOOST_TEST(*instance == 3);
+    }
+    BOOST_TEST(counting_allocator<sum>::n_allocated == 1); 
+    BOOST_TEST(counting_allocator<sum>::n_deallocated == 1);
+    {
+      boost::shared_ptr<sum> instance(
+          boost::factory< boost::shared_ptr<sum>, counting_allocator<void>,
+              boost::factory_passes_alloc_to_smart_pointer >()(one,two) );
+      BOOST_TEST(*instance == 3);
+    }
+    BOOST_TEST(counting_allocator<sum>::n_allocated == 2); 
+    BOOST_TEST(counting_allocator<sum>::n_deallocated == 2);
+    return boost::report_errors();
+}
+
diff --git a/factory/test/factory_with_none_t.cpp b/factory/test/factory_with_none_t.cpp
new file mode 100644
index 0000000..e8a515a
--- /dev/null
+++ b/factory/test/factory_with_none_t.cpp
@@ -0,0 +1,56 @@
+/*=============================================================================
+    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/core/lightweight_test.hpp>
+#include <boost/none_t.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; }
+};
+
+// Suppress warnings about std::auto_ptr.
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
+int main()
+{
+    int one = 1, two = 2;
+    {
+      sum* instance( boost::factory< sum*, boost::none_t >()(one,two) );
+      BOOST_TEST(*instance == 3);
+    }
+#if !defined(BOOST_NO_AUTO_PTR)
+    {
+      std::auto_ptr<sum> instance(
+              boost::factory< std::auto_ptr<sum>, boost::none_t >()(one,two) );
+      BOOST_TEST(*instance == 3);
+    }
+#endif
+#if !defined(BOOST_NO_CXX11_SMART_PTR)
+    {
+      std::unique_ptr<sum> instance(
+              boost::factory< std::unique_ptr<sum>, boost::none_t >()(one,two) );
+      BOOST_TEST(*instance == 3);
+    }
+#endif
+    return boost::report_errors();
+}
+
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
diff --git a/factory/test/factory_with_std_allocator.cpp b/factory/test/factory_with_std_allocator.cpp
new file mode 100644
index 0000000..2a58a60
--- /dev/null
+++ b/factory/test/factory_with_std_allocator.cpp
@@ -0,0 +1,45 @@
+/*=============================================================================
+    Copyright (c) 2007 Tobias Schwinger
+    Copyright (c) 2017 Daniel James
+
+    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 <cstddef>
+#include <memory>
+#include <boost/shared_ptr.hpp>
+
+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;
+    {
+      boost::shared_ptr<sum> instance(
+          boost::factory< boost::shared_ptr<sum>, std::allocator<int>,
+              boost::factory_alloc_for_pointee_and_deleter >()(one,two) );
+      BOOST_TEST(*instance == 3);
+    }
+
+    {
+      boost::shared_ptr<sum> instance(
+          boost::factory< boost::shared_ptr<sum>, std::allocator<int>,
+              boost::factory_passes_alloc_to_smart_pointer >()(one,two) );
+      BOOST_TEST(*instance == 3);
+    }
+
+    return boost::report_errors();
+}
+
diff --git a/factory/test/value_factory.cpp b/factory/test/value_factory.cpp
new file mode 100644
index 0000000..331757d
--- /dev/null
+++ b/factory/test/value_factory.cpp
@@ -0,0 +1,29 @@
+/*=============================================================================
+    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/value_factory.hpp>
+#include <boost/core/lightweight_test.hpp>
+
+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::value_factory< sum >()(one,two) );
+      BOOST_TEST(instance == 3);
+    }
+    return boost::report_errors();
+}
+