2 Copyright 2019 Glen Joseph Fernandes
5 Distributed under the Boost Software License, Version 1.0.
6 (http://www.boost.org/LICENSE_1_0.txt)
8 #include <boost/functional/factory.hpp>
9 #include <boost/core/lightweight_test.hpp>
10 #include <boost/smart_ptr/shared_ptr.hpp>
13 explicit type(bool b
) {
30 typedef creator
<U
> other
;
36 creator(const creator
<U
>&) { }
38 T
* allocate(std::size_t size
) {
40 return static_cast<T
*>(::operator new(sizeof(T
) * size
));
43 void deallocate(T
* ptr
, std::size_t) {
45 ::operator delete(ptr
);
50 int creator
<T
>::count
= 0;
52 template<class T
, class U
>
54 operator==(const creator
<T
>&, const creator
<U
>&)
59 template<class T
, class U
>
61 operator!=(const creator
<T
>&, const creator
<U
>&)
70 boost::shared_ptr
<type
> s(boost::factory
<boost::shared_ptr
<type
>,
72 boost::factory_alloc_for_pointee_and_deleter
>()(b
));
74 BOOST_TEST(creator
<type
>::count
== 0);
77 boost::shared_ptr
<type
> s(boost::factory
<boost::shared_ptr
<type
>,
79 boost::factory_passes_alloc_to_smart_pointer
>()(b
));
81 BOOST_TEST(creator
<type
>::count
== 0);
83 return boost::report_errors();