From 270d59be4e5436128f7b179d1ea9f21896db5e95 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 17 Dec 2017 11:43:35 +0000 Subject: [PATCH] Add extra test for factory with std::allocator So that it doesn't have to have warnings disabled, as in the other allocator test. --- factory/test/Jamfile | 2 + factory/test/factory_with_std_allocator.cpp | 45 +++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 factory/test/factory_with_std_allocator.cpp diff --git a/factory/test/Jamfile b/factory/test/Jamfile index fe5041f..c4a06af 100644 --- a/factory/test/Jamfile +++ b/factory/test/Jamfile @@ -14,9 +14,11 @@ 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 : : : 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_std_allocator.cpp : : : BOOST_FUNCTIONAL_FACTORY_SUPPORT_NONE_T : none_t_factory_with_std_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_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 +#include + +#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; + { + boost::shared_ptr instance( + boost::factory< boost::shared_ptr, std::allocator, + boost::factory_alloc_for_pointee_and_deleter >()(one,two) ); + BOOST_TEST(*instance == 3); + } + + { + boost::shared_ptr instance( + boost::factory< boost::shared_ptr, std::allocator, + boost::factory_passes_alloc_to_smart_pointer >()(one,two) ); + BOOST_TEST(*instance == 3); + } + + return boost::report_errors(); +} +