2014-01-28 03:58:51 -08:00
|
|
|
/*
|
2015-11-08 00:38:22 -05:00
|
|
|
(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
|
|
|
|
*/
|
2014-01-28 03:58:51 -08:00
|
|
|
#include <boost/config.hpp>
|
2014-01-31 11:01:37 -08:00
|
|
|
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
2014-01-28 03:58:51 -08:00
|
|
|
#include <boost/detail/lightweight_test.hpp>
|
2015-11-08 00:38:22 -05:00
|
|
|
#include <boost/smart_ptr/make_unique.hpp>
|
2014-01-28 03:58:51 -08:00
|
|
|
|
|
|
|
class type {
|
|
|
|
public:
|
|
|
|
static unsigned int instances;
|
|
|
|
|
|
|
|
explicit type() {
|
|
|
|
instances++;
|
|
|
|
}
|
|
|
|
|
|
|
|
~type() {
|
|
|
|
instances--;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
type(const type&);
|
|
|
|
type& operator=(const type&);
|
|
|
|
};
|
|
|
|
|
|
|
|
unsigned int type::instances = 0;
|
|
|
|
|
2015-11-08 00:38:22 -05:00
|
|
|
int main()
|
|
|
|
{
|
2014-01-28 03:58:51 -08:00
|
|
|
{
|
|
|
|
std::unique_ptr<int[]> a1 = boost::make_unique_noinit<int[]>(3);
|
|
|
|
BOOST_TEST(a1.get() != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
std::unique_ptr<int[][2]> a1 = boost::make_unique_noinit<int[][2]>(2);
|
|
|
|
BOOST_TEST(a1.get() != 0);
|
|
|
|
}
|
2014-01-29 16:33:32 -08:00
|
|
|
|
2014-01-28 03:58:51 -08:00
|
|
|
BOOST_TEST(type::instances == 0);
|
|
|
|
{
|
|
|
|
std::unique_ptr<type[]> a1 = boost::make_unique_noinit<type[]>(3);
|
|
|
|
BOOST_TEST(a1.get() != 0);
|
|
|
|
BOOST_TEST(type::instances == 3);
|
|
|
|
a1.reset();
|
|
|
|
BOOST_TEST(type::instances == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_TEST(type::instances == 0);
|
|
|
|
{
|
|
|
|
std::unique_ptr<type[][2]> a1 = boost::make_unique_noinit<type[][2]>(2);
|
|
|
|
BOOST_TEST(a1.get() != 0);
|
|
|
|
BOOST_TEST(type::instances == 4);
|
|
|
|
a1.reset();
|
|
|
|
BOOST_TEST(type::instances == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_TEST(type::instances == 0);
|
|
|
|
{
|
|
|
|
std::unique_ptr<const type[]> a1 = boost::make_unique_noinit<const type[]>(3);
|
|
|
|
BOOST_TEST(a1.get() != 0);
|
|
|
|
BOOST_TEST(type::instances == 3);
|
|
|
|
a1.reset();
|
|
|
|
BOOST_TEST(type::instances == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_TEST(type::instances == 0);
|
|
|
|
{
|
|
|
|
std::unique_ptr<const type[][2]> a1 = boost::make_unique_noinit<const type[][2]>(2);
|
|
|
|
BOOST_TEST(a1.get() != 0);
|
|
|
|
BOOST_TEST(type::instances == 4);
|
|
|
|
a1.reset();
|
|
|
|
BOOST_TEST(type::instances == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return boost::report_errors();
|
|
|
|
}
|
2014-01-31 11:01:37 -08:00
|
|
|
#else
|
|
|
|
|
2015-11-08 00:38:22 -05:00
|
|
|
int main()
|
|
|
|
{
|
2014-01-31 11:01:37 -08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|