diff --git a/include/boost/smart_ptr/make_unique.hpp b/include/boost/smart_ptr/make_unique.hpp
index d054e3d..eed5033 100644
--- a/include/boost/smart_ptr/make_unique.hpp
+++ b/include/boost/smart_ptr/make_unique.hpp
@@ -1,10 +1,9 @@
/*
-(c) 2014-2015 Glen Joseph Fernandes
-
+Copyright 2012-2015 Glen Joseph Fernandes
+(glenjofe@gmail.com)
-Distributed under the Boost Software
-License, Version 1.0.
-http://boost.org/LICENSE_1_0.txt
+Distributed under the Boost Software License, Version 1.0.
+(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_SMART_PTR_MAKE_UNIQUE_HPP
#define BOOST_SMART_PTR_MAKE_UNIQUE_HPP
@@ -15,6 +14,7 @@ http://boost.org/LICENSE_1_0.txt
namespace boost {
namespace detail {
+
template
struct up_if_object {
typedef std::unique_ptr type;
@@ -56,10 +56,12 @@ template
struct up_element {
typedef T type;
};
+
} /* detail */
template
-inline typename detail::up_if_object::type make_unique()
+inline typename detail::up_if_object::type
+make_unique()
{
return std::unique_ptr(new T());
}
@@ -67,7 +69,7 @@ inline typename detail::up_if_object::type make_unique()
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template
inline typename detail::up_if_object::type
- make_unique(Args&&... args)
+make_unique(Args&&... args)
{
return std::unique_ptr(new T(std::forward(args)...));
}
@@ -75,31 +77,34 @@ inline typename detail::up_if_object::type
template
inline typename detail::up_if_object::type
- make_unique(typename detail::up_remove_reference::type&& value)
+make_unique(typename detail::up_remove_reference::type&& value)
{
return std::unique_ptr(new T(std::move(value)));
}
template
-inline typename detail::up_if_object::type make_unique_noinit()
+inline typename detail::up_if_object::type
+make_unique_noinit()
{
return std::unique_ptr(new T);
}
template
-inline typename detail::up_if_array::type make_unique(std::size_t n)
+inline typename detail::up_if_array::type
+make_unique(std::size_t size)
{
- return std::unique_ptr(new
- typename detail::up_element::type[n]());
+ return std::unique_ptr(new typename
+ detail::up_element::type[size]());
}
template
inline typename detail::up_if_array::type
- make_unique_noinit(std::size_t n)
+make_unique_noinit(std::size_t size)
{
- return std::unique_ptr(new
- typename detail::up_element::type[n]);
+ return std::unique_ptr(new typename
+ detail::up_element::type[size]);
}
+
} /* boost */
#endif
diff --git a/make_unique.html b/make_unique.html
index 5b414e8..b649245 100644
--- a/make_unique.html
+++ b/make_unique.html
@@ -21,10 +21,8 @@
template<class U> // U is not array
unique_ptr<U> make_unique();
-#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class U, class... Args> // U is not array
unique_ptr<U> make_unique(Args&&... args);
-#endif
template<class U> // U is not array
unique_ptr<U> make_unique(U&& value);
@@ -40,9 +38,9 @@
}
template<class U>
- unique_ptr<U> make_unique(args);
-template<class U>
- unique_ptr<U> make_unique_noinit(args);
+unique_ptr<U> make_unique(args);
+ template<class U>
+unique_ptr<U> make_unique_noinit(args);
Effects: Allocates memory for an object of type U
(or T[size]
when U
is T[]
,
@@ -82,8 +80,8 @@ unique_ptr<U> make_unique(Args&&... args);
resolution when U
is not an array type.
Examples:
- unique_ptr<float> p1 = boost::make_unique<float>();
-unique_ptr<point> p2 = boost::make_unique<point>(x, y);
+ unique_ptr<float> p1 = boost::make_unique<float>();
+ unique_ptr<point> p2 = boost::make_unique<point>(x, y);
template<class U>
@@ -95,8 +93,8 @@ unique_ptr<U> make_unique(U&& value);
resolution when U
is not an array type.
Examples:
- unique_ptr<string> p1 = boost::make_unique<string>({'a', 'b'});
-unique_ptr<point> p2 = boost::make_unique<point>({-10, 25});
+ unique_ptr<string> p1 = boost::make_unique<string>({'a', 'b'});
+ unique_ptr<point> p2 = boost::make_unique<point>({-10, 25});
template<class U>
@@ -108,8 +106,8 @@ unique_ptr<U> make_unique(size_t size);
resolution when U
is of the form T[]
.
Examples:
- unique_ptr<double[]> p1 = boost::make_unique<double[]>(4);
-unique_ptr<int[][2]> p2 = boost::make_unique<int[][2]>(2);
+ unique_ptr<double[]> p1 = boost::make_unique<double[]>(4);
+ unique_ptr<int[][2]> p2 = boost::make_unique<int[][2]>(2);
template<class U>
@@ -121,8 +119,8 @@ unique_ptr<U> make_unique_noinit();
resolution when U
is not an array type.
Examples:
- unique_ptr<float> p1 = boost::make_unique_noinit<float>();
-unique_ptr<point> p2 = boost::make_unique_noinit<point>();
+ unique_ptr<float> p1 = boost::make_unique_noinit<float>();
+ unique_ptr<point> p2 = boost::make_unique_noinit<point>();
template<class U>
@@ -134,8 +132,8 @@ unique_ptr<U> make_unique_noinit(size_t size);
resolution when U
is of the form T[]
.
Examples:
- unique_ptr<double[]> p1 = boost::make_unique_noinit<double[]>(4);
-unique_ptr<int[][2]> p2 = boost::make_unique_noinit<int[][2]>(2);
+ unique_ptr<double[]> p1 = boost::make_unique_noinit<double[]>(4);
+ unique_ptr<int[][2]> p2 = boost::make_unique_noinit<int[][2]>(2);
diff --git a/test/allocate_shared_array_construct_test.cpp b/test/allocate_shared_array_construct_test.cpp
index 0228275..669e813 100644
--- a/test/allocate_shared_array_construct_test.cpp
+++ b/test/allocate_shared_array_construct_test.cpp
@@ -1,127 +1,162 @@
/*
-(c) 2012-2015 Glen Joseph Fernandes
-
+Copyright 2012-2015 Glen Joseph Fernandes
+(glenjofe@gmail.com)
-Distributed under the Boost Software
-License, Version 1.0.
-http://boost.org/LICENSE_1_0.txt
+Distributed under the Boost Software License, Version 1.0.
+(http://www.boost.org/LICENSE_1_0.txt)
*/
#include
#include
-struct tag { };
+#if !defined(BOOST_NO_CXX11_ALLOCATOR)
+struct allow { };
-template
-class creator {
-public:
+template
+struct creator {
typedef T value_type;
- creator() {
- }
- template
- creator(const creator&) {
- }
+
+ template
+ struct rebind {
+ typedef creator other;
+ };
+
+ creator() { }
+
+ template
+ creator(const creator&) { }
+
T* allocate(std::size_t size) {
- void* p = ::operator new(size * sizeof(T));
- return static_cast(p);
+ return static_cast(::operator new(sizeof(T) * size));
}
- void deallocate(T* memory, std::size_t) {
- void* p = memory;
- ::operator delete(p);
+
+ void deallocate(T* ptr, std::size_t) {
+ ::operator delete(ptr);
}
- template
- void construct(U* memory) {
- void* p = memory;
- ::new(p) U(tag());
+
+ template
+ void construct(U* ptr) {
+ ::new(static_cast(ptr)) U(allow());
}
- template
- void destroy(U* memory) {
- memory->~U();
+
+ template
+ void destroy(U* ptr) {
+ ptr->~U();
}
+
};
+template
+inline bool
+operator==(const creator&, const creator&)
+{
+ return true;
+}
+
+template
+inline bool
+operator!=(const creator&, const creator&)
+{
+ return false;
+}
+
class type {
public:
- static unsigned int instances;
- explicit type(tag) {
- instances++;
- }
- type(const type&) {
- instances++;
+ static unsigned instances;
+
+ explicit type(allow) {
+ ++instances;
}
+
~type() {
- instances--;
+ --instances;
}
+
+private:
+ type(const type&);
+ type& operator=(const type&);
};
-unsigned int type::instances = 0;
+unsigned type::instances = 0;
int main()
{
-#if !defined(BOOST_NO_CXX11_ALLOCATOR)
{
- boost::shared_ptr a1 = boost::allocate_shared(creator(), 3);
- BOOST_TEST(a1.use_count() == 1);
- BOOST_TEST(a1.get() != 0);
+ boost::shared_ptr result =
+ boost::allocate_shared(creator(), 3);
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 3);
- a1.reset();
+ result.reset();
BOOST_TEST(type::instances == 0);
}
{
- boost::shared_ptr a1 = boost::allocate_shared(creator());
- BOOST_TEST(a1.use_count() == 1);
- BOOST_TEST(a1.get() != 0);
+ boost::shared_ptr result =
+ boost::allocate_shared(creator());
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 3);
- a1.reset();
+ result.reset();
BOOST_TEST(type::instances == 0);
}
{
- boost::shared_ptr a1 = boost::allocate_shared(creator(), 2);
- BOOST_TEST(a1.get() != 0);
- BOOST_TEST(a1.use_count() == 1);
+ boost::shared_ptr result =
+ boost::allocate_shared(creator(), 2);
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 4);
- a1.reset();
+ result.reset();
BOOST_TEST(type::instances == 0);
}
{
- boost::shared_ptr a1 = boost::allocate_shared(creator());
- BOOST_TEST(a1.get() != 0);
- BOOST_TEST(a1.use_count() == 1);
+ boost::shared_ptr result =
+ boost::allocate_shared(creator());
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 4);
- a1.reset();
+ result.reset();
BOOST_TEST(type::instances == 0);
}
{
- boost::shared_ptr a1 = boost::allocate_shared(creator(), 3);
- BOOST_TEST(a1.get() != 0);
- BOOST_TEST(a1.use_count() == 1);
+ boost::shared_ptr result =
+ boost::allocate_shared(creator(), 3);
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 3);
- a1.reset();
+ result.reset();
BOOST_TEST(type::instances == 0);
}
{
- boost::shared_ptr a1 = boost::allocate_shared(creator());
- BOOST_TEST(a1.get() != 0);
- BOOST_TEST(a1.use_count() == 1);
+ boost::shared_ptr result =
+ boost::allocate_shared(creator());
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 3);
- a1.reset();
+ result.reset();
BOOST_TEST(type::instances == 0);
}
{
- boost::shared_ptr a1 = boost::allocate_shared(creator(), 2);
- BOOST_TEST(a1.get() != 0);
- BOOST_TEST(a1.use_count() == 1);
+ boost::shared_ptr result =
+ boost::allocate_shared(creator(), 2);
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 4);
- a1.reset();
+ result.reset();
BOOST_TEST(type::instances == 0);
}
{
- boost::shared_ptr a1 = boost::allocate_shared(creator());
- BOOST_TEST(a1.get() != 0);
- BOOST_TEST(a1.use_count() == 1);
+ boost::shared_ptr result =
+ boost::allocate_shared(creator());
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 4);
- a1.reset();
+ result.reset();
BOOST_TEST(type::instances == 0);
}
-#endif
return boost::report_errors();
}
+#else
+int main()
+{
+ return 0;
+}
+#endif
diff --git a/test/allocate_shared_array_esft_test.cpp b/test/allocate_shared_array_esft_test.cpp
index 30edfff..0399c1a 100644
--- a/test/allocate_shared_array_esft_test.cpp
+++ b/test/allocate_shared_array_esft_test.cpp
@@ -1,39 +1,79 @@
/*
-(c) 2012-2015 Glen Joseph Fernandes
-
+Copyright 2012-2015 Glen Joseph Fernandes
+(glenjofe@gmail.com)
-Distributed under the Boost Software
-License, Version 1.0.
-http://boost.org/LICENSE_1_0.txt
+Distributed under the Boost Software License, Version 1.0.
+(http://www.boost.org/LICENSE_1_0.txt)
*/
#include
#include
#include
-class type
+template
+struct creator {
+ typedef T value_type;
+
+ template
+ struct rebind {
+ typedef creator other;
+ };
+
+ creator() { }
+
+ template
+ creator(const creator&) { }
+
+ T* allocate(std::size_t size) {
+ return static_cast(::operator new(sizeof(T) * size));
+ }
+
+ void deallocate(T* ptr, std::size_t) {
+ ::operator delete(ptr);
+ }
+};
+
+template
+inline bool
+operator==(const creator&, const creator&)
+{
+ return true;
+}
+
+template
+inline bool
+operator!=(const creator&, const creator&)
+{
+ return false;
+}
+
+class type
: public boost::enable_shared_from_this {
public:
- static unsigned int instances;
- explicit type() {
- instances++;
+ static unsigned instances;
+
+ type() {
+ ++instances;
}
+
~type() {
- instances--;
+ --instances;
}
+
private:
type(const type&);
type& operator=(const type&);
};
-unsigned int type::instances = 0;
+unsigned type::instances = 0;
int main()
{
BOOST_TEST(type::instances == 0);
{
- boost::shared_ptr a1 = boost::allocate_shared(std::allocator(), 3);
+ boost::shared_ptr result =
+ boost::allocate_shared(creator(), 3);
try {
- a1[0].shared_from_this();
+ result[0].shared_from_this();
BOOST_ERROR("shared_from_this did not throw");
} catch (...) {
BOOST_TEST(type::instances == 3);
@@ -41,9 +81,10 @@ int main()
}
BOOST_TEST(type::instances == 0);
{
- boost::shared_ptr a1 = boost::allocate_shared_noinit(std::allocator(), 3);
+ boost::shared_ptr result =
+ boost::allocate_shared_noinit(creator(), 3);
try {
- a1[0].shared_from_this();
+ result[0].shared_from_this();
BOOST_ERROR("shared_from_this did not throw");
} catch (...) {
BOOST_TEST(type::instances == 3);
diff --git a/test/allocate_shared_array_noinit_test.cpp b/test/allocate_shared_array_noinit_test.cpp
index 83b48ec..f30ee17 100644
--- a/test/allocate_shared_array_noinit_test.cpp
+++ b/test/allocate_shared_array_noinit_test.cpp
@@ -1,154 +1,250 @@
/*
-(c) 2012-2015 Glen Joseph Fernandes
-
+Copyright 2012-2015 Glen Joseph Fernandes
+(glenjofe@gmail.com)
-Distributed under the Boost Software
-License, Version 1.0.
-http://boost.org/LICENSE_1_0.txt
+Distributed under the Boost Software License, Version 1.0.
+(http://www.boost.org/LICENSE_1_0.txt)
*/
+#include
#include
#include
#include
#include
+template
+struct creator {
+ typedef T value_type;
+
+ template
+ struct rebind {
+ typedef creator other;
+ };
+
+ creator() { }
+
+ template
+ creator(const creator&) { }
+
+ T* allocate(std::size_t size) {
+ return static_cast(::operator new(sizeof(T) * size));
+ }
+
+ void deallocate(T* ptr, std::size_t) {
+ ::operator delete(ptr);
+ }
+};
+
+template
+inline bool
+operator==(const creator&, const creator&)
+{
+ return true;
+}
+
+template
+inline bool
+operator!=(const creator&, const creator&)
+{
+ return false;
+}
+
class type {
public:
- static unsigned int instances;
- explicit type() {
- instances++;
+ static unsigned instances;
+
+ type()
+ : value_(0.0) {
+ ++instances;
}
+
~type() {
- instances--;
+ --instances;
}
+
+ void set(long double value) {
+ value_ = value;
+ }
+
+ long double get() const {
+ return value_;
+ }
+
private:
type(const type&);
type& operator=(const type&);
+
+ long double value_;
};
-unsigned int type::instances = 0;
+unsigned type::instances = 0;
int main()
{
{
- boost::shared_ptr a1 = boost::allocate_shared_noinit(std::allocator(), 3);
- int* a2 = a1.get();
- BOOST_TEST(a1.use_count() == 1);
- BOOST_TEST(a2 != 0);
- BOOST_TEST(size_t(a2) % boost::alignment_of::value == 0);
+ boost::shared_ptr result =
+ boost::allocate_shared_noinit(creator(), 3);
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
+ BOOST_TEST(boost::alignment::is_aligned(result.get(),
+ boost::alignment_of::value));
}
{
- boost::shared_ptr a1 = boost::allocate_shared_noinit(std::allocator());
- int* a2 = a1.get();
- BOOST_TEST(a1.use_count() == 1);
- BOOST_TEST(a2 != 0);
- BOOST_TEST(size_t(a2) % boost::alignment_of::value == 0);
+ boost::shared_ptr result =
+ boost::allocate_shared_noinit(creator());
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
+ BOOST_TEST(boost::alignment::is_aligned(result.get(),
+ boost::alignment_of::value));
}
{
- boost::shared_ptr a1 = boost::allocate_shared_noinit(std::allocator(), 2);
- BOOST_TEST(a1.get() != 0);
- BOOST_TEST(a1.use_count() == 1);
+ boost::shared_ptr result =
+ boost::allocate_shared_noinit(creator(), 2);
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
+ BOOST_TEST(boost::alignment::is_aligned(result.get(),
+ boost::alignment_of::value));
}
{
- boost::shared_ptr a1 = boost::allocate_shared_noinit(std::allocator());
- BOOST_TEST(a1.get() != 0);
- BOOST_TEST(a1.use_count() == 1);
+ boost::shared_ptr result =
+ boost::allocate_shared_noinit(creator());
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
+ BOOST_TEST(boost::alignment::is_aligned(result.get(),
+ boost::alignment_of::value));
}
{
- boost::shared_ptr a1 = boost::allocate_shared_noinit(std::allocator(), 3);
- const int* a2 = a1.get();
- BOOST_TEST(a1.use_count() == 1);
- BOOST_TEST(a2 != 0);
- BOOST_TEST(size_t(a2) % boost::alignment_of::value == 0);
+ boost::shared_ptr result =
+ boost::allocate_shared_noinit(creator(), 3);
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
+ BOOST_TEST(boost::alignment::is_aligned(result.get(),
+ boost::alignment_of::value));
}
{
- boost::shared_ptr a1 = boost::allocate_shared_noinit(std::allocator());
- const int* a2 = a1.get();
- BOOST_TEST(a1.use_count() == 1);
- BOOST_TEST(a2 != 0);
- BOOST_TEST(size_t(a2) % boost::alignment_of::value == 0);
+ boost::shared_ptr result =
+ boost::allocate_shared_noinit(creator());
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
+ BOOST_TEST(boost::alignment::is_aligned(result.get(),
+ boost::alignment_of::value));
}
{
- boost::shared_ptr a1 = boost::allocate_shared_noinit(std::allocator(), 2);
- BOOST_TEST(a1.get() != 0);
- BOOST_TEST(a1.use_count() == 1);
+ boost::shared_ptr result =
+ boost::allocate_shared_noinit(creator(), 2);
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
+ BOOST_TEST(boost::alignment::is_aligned(result.get(),
+ boost::alignment_of::value));
}
{
- boost::shared_ptr a1 = boost::allocate_shared_noinit(std::allocator());
- BOOST_TEST(a1.get() != 0);
- BOOST_TEST(a1.use_count() == 1);
+ boost::shared_ptr result =
+ boost::allocate_shared_noinit(creator());
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
+ BOOST_TEST(boost::alignment::is_aligned(result.get(),
+ boost::alignment_of::value));
}
{
- boost::shared_ptr a1 = boost::allocate_shared_noinit(std::allocator(), 3);
- type* a2 = a1.get();
- BOOST_TEST(a1.use_count() == 1);
- BOOST_TEST(a2 != 0);
- BOOST_TEST(size_t(a2) % boost::alignment_of::value == 0);
+ boost::shared_ptr result =
+ boost::allocate_shared_noinit(creator(), 3);
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
+ BOOST_TEST(boost::alignment::is_aligned(result.get(),
+ boost::alignment_of::value));
BOOST_TEST(type::instances == 3);
- boost::weak_ptr w1 = a1;
- a1.reset();
+ boost::weak_ptr other = result;
+ result.reset();
BOOST_TEST(type::instances == 0);
}
{
- boost::shared_ptr a1 = boost::allocate_shared_noinit(std::allocator());
- type* a2 = a1.get();
- BOOST_TEST(a1.use_count() == 1);
- BOOST_TEST(a2 != 0);
- BOOST_TEST(size_t(a2) % boost::alignment_of::value == 0);
+ boost::shared_ptr result =
+ boost::allocate_shared_noinit(creator());
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
+ BOOST_TEST(boost::alignment::is_aligned(result.get(),
+ boost::alignment_of::value));
BOOST_TEST(type::instances == 3);
- boost::weak_ptr w1 = a1;
- a1.reset();
+ boost::weak_ptr other = result;
+ result.reset();
BOOST_TEST(type::instances == 0);
}
{
- boost::shared_ptr a1 = boost::allocate_shared_noinit(std::allocator(), 2);
- BOOST_TEST(a1.get() != 0);
- BOOST_TEST(a1.use_count() == 1);
+ boost::shared_ptr result =
+ boost::allocate_shared_noinit(creator(), 2);
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
+ BOOST_TEST(boost::alignment::is_aligned(result.get(),
+ boost::alignment_of::value));
BOOST_TEST(type::instances == 4);
- a1.reset();
+ boost::weak_ptr other = result;
+ result.reset();
BOOST_TEST(type::instances == 0);
}
{
- boost::shared_ptr a1 = boost::allocate_shared_noinit(std::allocator());
- BOOST_TEST(a1.get() != 0);
- BOOST_TEST(a1.use_count() == 1);
+ boost::shared_ptr result =
+ boost::allocate_shared_noinit(creator());
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
+ BOOST_TEST(boost::alignment::is_aligned(result.get(),
+ boost::alignment_of::value));
BOOST_TEST(type::instances == 4);
- a1.reset();
+ boost::weak_ptr other = result;
+ result.reset();
BOOST_TEST(type::instances == 0);
}
{
- boost::shared_ptr a1 = boost::allocate_shared_noinit(std::allocator(), 3);
- const type* a2 = a1.get();
- BOOST_TEST(a1.use_count() == 1);
- BOOST_TEST(a2 != 0);
- BOOST_TEST(size_t(a2) % boost::alignment_of::value == 0);
+ boost::shared_ptr result =
+ boost::allocate_shared_noinit(creator(), 3);
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
+ BOOST_TEST(boost::alignment::is_aligned(result.get(),
+ boost::alignment_of::value));
BOOST_TEST(type::instances == 3);
- a1.reset();
+ boost::weak_ptr other = result;
+ result.reset();
BOOST_TEST(type::instances == 0);
}
{
- boost::shared_ptr a1 = boost::allocate_shared_noinit(std::allocator());
- const type* a2 = a1.get();
- BOOST_TEST(a1.use_count() == 1);
- BOOST_TEST(a2 != 0);
- BOOST_TEST(size_t(a2) % boost::alignment_of::value == 0);
+ boost::shared_ptr result =
+ boost::allocate_shared_noinit(creator());
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
+ BOOST_TEST(boost::alignment::is_aligned(result.get(),
+ boost::alignment_of::value));
BOOST_TEST(type::instances == 3);
- a1.reset();
+ boost::weak_ptr other = result;
+ result.reset();
BOOST_TEST(type::instances == 0);
}
{
- boost::shared_ptr a1 = boost::allocate_shared_noinit(std::allocator(), 2);
- BOOST_TEST(a1.get() != 0);
- BOOST_TEST(a1.use_count() == 1);
+ boost::shared_ptr result =
+ boost::allocate_shared_noinit(creator(), 2);
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
+ BOOST_TEST(boost::alignment::is_aligned(result.get(),
+ boost::alignment_of::value));
BOOST_TEST(type::instances == 4);
- a1.reset();
+ boost::weak_ptr other = result;
+ result.reset();
BOOST_TEST(type::instances == 0);
}
{
- boost::shared_ptr a1 = boost::allocate_shared_noinit(std::allocator());
- BOOST_TEST(a1.get() != 0);
- BOOST_TEST(a1.use_count() == 1);
+ boost::shared_ptr result =
+ boost::allocate_shared_noinit(creator());
+ BOOST_TEST(result.get() != 0);
+ BOOST_TEST(result.use_count() == 1);
+ BOOST_TEST(boost::alignment::is_aligned(result.get(),
+ boost::alignment_of::value));
BOOST_TEST(type::instances == 4);
- a1.reset();
+ boost::weak_ptr other = result;
+ result.reset();
BOOST_TEST(type::instances == 0);
}
return boost::report_errors();
diff --git a/test/allocate_shared_array_test.cpp b/test/allocate_shared_array_test.cpp
index c5a5714..0369631 100644
--- a/test/allocate_shared_array_test.cpp
+++ b/test/allocate_shared_array_test.cpp
@@ -1,182 +1,265 @@
/*
-(c) 2012-2015 Glen Joseph Fernandes
-
+Copyright 2012-2015 Glen Joseph Fernandes
+(glenjofe@gmail.com)
-Distributed under the Boost Software
-License, Version 1.0.
-http://boost.org/LICENSE_1_0.txt
+Distributed under the Boost Software License, Version 1.0.
+(http://www.boost.org/LICENSE_1_0.txt)
*/
+#include
#include
#include
#include