mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-10-14 00:15:28 +02:00
Update make_shared for arrays to conform to N3870
Update make_shared and allocate_shared for arrays to be confined to the set of overloads specified in N3870.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Glen Joseph Fernandes
|
||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
||||
* glenfe at live dot com
|
||||
*
|
||||
* Distributed under the Boost Software License,
|
||||
@@ -12,15 +12,18 @@
|
||||
class type {
|
||||
public:
|
||||
static unsigned int instances;
|
||||
|
||||
explicit type() {
|
||||
if (instances == 5) {
|
||||
throw true;
|
||||
}
|
||||
instances++;
|
||||
}
|
||||
|
||||
~type() {
|
||||
instances--;
|
||||
}
|
||||
|
||||
private:
|
||||
type(const type&);
|
||||
type& operator=(const type&);
|
||||
@@ -36,6 +39,7 @@ int main() {
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
|
||||
BOOST_TEST(type::instances == 0);
|
||||
try {
|
||||
boost::make_shared<type[][2]>(3);
|
||||
@@ -43,7 +47,7 @@ int main() {
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
BOOST_TEST(type::instances == 0);
|
||||
try {
|
||||
boost::make_shared<type[6]>();
|
||||
@@ -51,6 +55,7 @@ int main() {
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
|
||||
BOOST_TEST(type::instances == 0);
|
||||
try {
|
||||
boost::make_shared<type[3][2]>();
|
||||
@@ -58,7 +63,7 @@ int main() {
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
BOOST_TEST(type::instances == 0);
|
||||
try {
|
||||
boost::make_shared_noinit<type[]>(6);
|
||||
@@ -66,6 +71,7 @@ int main() {
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
|
||||
BOOST_TEST(type::instances == 0);
|
||||
try {
|
||||
boost::make_shared_noinit<type[][2]>(3);
|
||||
@@ -73,5 +79,24 @@ int main() {
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
|
||||
BOOST_TEST(type::instances == 0);
|
||||
try {
|
||||
boost::make_shared_noinit<type[6]>();
|
||||
BOOST_ERROR("make_shared_noinit did not throw");
|
||||
}
|
||||
catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
|
||||
BOOST_TEST(type::instances == 0);
|
||||
try {
|
||||
boost::make_shared_noinit<type[3][2]>();
|
||||
BOOST_ERROR("make_shared_noinit did not throw");
|
||||
}
|
||||
catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
Reference in New Issue
Block a user