forked from boostorg/smart_ptr
Refactor make_unique implementations
Before the pending refactor of make_shared/allocate_shared for arrays.
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Glen Joseph Fernandes
|
||||
* glenfe at live dot com
|
||||
*
|
||||
* Distributed under the Boost Software License,
|
||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
(c) 2014 Glen Joseph Fernandes
|
||||
<glenjofe -at- gmail.com>
|
||||
|
||||
Distributed under the Boost Software
|
||||
License, Version 1.0.
|
||||
http://boost.org/LICENSE_1_0.txt
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_unique_object.hpp>
|
||||
#include <boost/smart_ptr/make_unique.hpp>
|
||||
|
||||
class type {
|
||||
public:
|
||||
@@ -41,7 +41,8 @@ private:
|
||||
|
||||
unsigned int type::instances = 0;
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
std::unique_ptr<type> a1 = boost::make_unique<type>();
|
||||
@@ -139,7 +140,8 @@ int main() {
|
||||
}
|
||||
#else
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
||||
* glenfe at live dot com
|
||||
*
|
||||
* Distributed under the Boost Software License,
|
||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
(c) 2014 Glen Joseph Fernandes
|
||||
<glenjofe -at- gmail.com>
|
||||
|
||||
Distributed under the Boost Software
|
||||
License, Version 1.0.
|
||||
http://boost.org/LICENSE_1_0.txt
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_unique_array.hpp>
|
||||
#include <boost/smart_ptr/make_unique.hpp>
|
||||
|
||||
class type {
|
||||
public:
|
||||
@@ -30,7 +30,8 @@ private:
|
||||
|
||||
unsigned int type::instances = 0;
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::unique_ptr<int[]> a1 = boost::make_unique_noinit<int[]>(3);
|
||||
BOOST_TEST(a1.get() != 0);
|
||||
@@ -81,7 +82,8 @@ int main() {
|
||||
}
|
||||
#else
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Glen Joseph Fernandes
|
||||
* glenfe at live dot com
|
||||
*
|
||||
* Distributed under the Boost Software License,
|
||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
(c) 2014 Glen Joseph Fernandes
|
||||
<glenjofe -at- gmail.com>
|
||||
|
||||
Distributed under the Boost Software
|
||||
License, Version 1.0.
|
||||
http://boost.org/LICENSE_1_0.txt
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_unique_array.hpp>
|
||||
#include <boost/smart_ptr/make_unique.hpp>
|
||||
|
||||
class type {
|
||||
public:
|
||||
@@ -30,7 +30,8 @@ private:
|
||||
|
||||
unsigned int type::instances = 0;
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::unique_ptr<int[]> a1 = boost::make_unique<int[]>(3);
|
||||
BOOST_TEST(a1.get() != 0);
|
||||
@@ -105,7 +106,8 @@ int main() {
|
||||
}
|
||||
#else
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Glen Joseph Fernandes
|
||||
* glenfe at live dot com
|
||||
*
|
||||
* Distributed under the Boost Software License,
|
||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
(c) 2014 Glen Joseph Fernandes
|
||||
<glenjofe -at- gmail.com>
|
||||
|
||||
Distributed under the Boost Software
|
||||
License, Version 1.0.
|
||||
http://boost.org/LICENSE_1_0.txt
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_unique_array.hpp>
|
||||
#include <boost/smart_ptr/make_unique.hpp>
|
||||
|
||||
class type {
|
||||
public:
|
||||
@@ -33,7 +33,8 @@ private:
|
||||
|
||||
unsigned int type::instances = 0;
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST(type::instances == 0);
|
||||
try {
|
||||
boost::make_unique<type[]>(6);
|
||||
@@ -70,7 +71,8 @@ int main() {
|
||||
}
|
||||
#else
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
||||
* glenfe at live dot com
|
||||
*
|
||||
* Distributed under the Boost Software License,
|
||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
(c) 2014 Glen Joseph Fernandes
|
||||
<glenjofe -at- gmail.com>
|
||||
|
||||
Distributed under the Boost Software
|
||||
License, Version 1.0.
|
||||
http://boost.org/LICENSE_1_0.txt
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_unique_object.hpp>
|
||||
#include <boost/smart_ptr/make_unique.hpp>
|
||||
|
||||
class type {
|
||||
public:
|
||||
@@ -30,7 +30,8 @@ private:
|
||||
|
||||
unsigned int type::instances = 0;
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::unique_ptr<int> a1 = boost::make_unique_noinit<int>();
|
||||
BOOST_TEST(a1.get() != 0);
|
||||
@@ -58,7 +59,8 @@ int main() {
|
||||
}
|
||||
#else
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+12
-10
@@ -1,15 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Glen Joseph Fernandes
|
||||
* glenfe at live dot com
|
||||
*
|
||||
* Distributed under the Boost Software License,
|
||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
(c) 2014 Glen Joseph Fernandes
|
||||
<glenjofe -at- gmail.com>
|
||||
|
||||
Distributed under the Boost Software
|
||||
License, Version 1.0.
|
||||
http://boost.org/LICENSE_1_0.txt
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_unique_object.hpp>
|
||||
#include <boost/smart_ptr/make_unique.hpp>
|
||||
|
||||
class type {
|
||||
public:
|
||||
@@ -30,7 +30,8 @@ private:
|
||||
|
||||
unsigned int type::instances = 0;
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::unique_ptr<int> a1 = boost::make_unique<int>();
|
||||
BOOST_TEST(a1.get() != 0);
|
||||
@@ -65,7 +66,8 @@ int main() {
|
||||
}
|
||||
#else
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Glen Joseph Fernandes
|
||||
* glenfe at live dot com
|
||||
*
|
||||
* Distributed under the Boost Software License,
|
||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
(c) 2014 Glen Joseph Fernandes
|
||||
<glenjofe -at- gmail.com>
|
||||
|
||||
Distributed under the Boost Software
|
||||
License, Version 1.0.
|
||||
http://boost.org/LICENSE_1_0.txt
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_unique_object.hpp>
|
||||
#include <boost/smart_ptr/make_unique.hpp>
|
||||
|
||||
class type {
|
||||
public:
|
||||
@@ -33,7 +33,8 @@ private:
|
||||
|
||||
unsigned int type::instances = 0;
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST(type::instances == 0);
|
||||
try {
|
||||
boost::make_unique<type>();
|
||||
@@ -46,7 +47,8 @@ int main() {
|
||||
}
|
||||
#else
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Glen Joseph Fernandes
|
||||
* glenfe at live dot com
|
||||
*
|
||||
* Distributed under the Boost Software License,
|
||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
(c) 2014 Glen Joseph Fernandes
|
||||
<glenjofe -at- gmail.com>
|
||||
|
||||
Distributed under the Boost Software
|
||||
License, Version 1.0.
|
||||
http://boost.org/LICENSE_1_0.txt
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_unique_object.hpp>
|
||||
#include <boost/smart_ptr/make_unique.hpp>
|
||||
|
||||
struct type {
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::unique_ptr<type> a1 = boost::make_unique<type>();
|
||||
BOOST_TEST(a1.get() != 0);
|
||||
@@ -51,7 +52,8 @@ int main() {
|
||||
}
|
||||
#else
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user