2010-05-11 21:42:16 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2010-05-11 23:36:01 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
2010-05-11 21:42:16 +02:00
|
|
|
//
|
2010-11-16 23:09:02 +01:00
|
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
|
|
// Source Licenses. See LICENSE.TXT for details.
|
2010-05-11 21:42:16 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// type_traits
|
|
|
|
|
|
|
|
// has_copy_constructor
|
|
|
|
|
|
|
|
#include <type_traits>
|
|
|
|
|
2010-09-08 01:11:28 +02:00
|
|
|
template <class T, bool Result>
|
|
|
|
void test_has_copy_constructor()
|
|
|
|
{
|
|
|
|
static_assert(std::has_copy_constructor<T>::value == Result, "");
|
|
|
|
}
|
|
|
|
|
|
|
|
class Empty
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
class NotEmpty
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~NotEmpty();
|
|
|
|
};
|
|
|
|
|
|
|
|
union Union {};
|
|
|
|
|
|
|
|
struct bit_zero
|
|
|
|
{
|
|
|
|
int : 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Abstract
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~Abstract() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct A
|
|
|
|
{
|
|
|
|
A(const A&);
|
|
|
|
};
|
|
|
|
|
2010-05-11 21:42:16 +02:00
|
|
|
int main()
|
|
|
|
{
|
2010-09-08 01:11:28 +02:00
|
|
|
test_has_copy_constructor<char[3], false>();
|
|
|
|
test_has_copy_constructor<char[], false>();
|
|
|
|
test_has_copy_constructor<void, false>();
|
|
|
|
test_has_copy_constructor<Abstract, false>();
|
|
|
|
|
|
|
|
test_has_copy_constructor<A, true>();
|
|
|
|
test_has_copy_constructor<int&, true>();
|
|
|
|
test_has_copy_constructor<Union, true>();
|
|
|
|
test_has_copy_constructor<Empty, true>();
|
|
|
|
test_has_copy_constructor<int, true>();
|
|
|
|
test_has_copy_constructor<double, true>();
|
|
|
|
test_has_copy_constructor<int*, true>();
|
|
|
|
test_has_copy_constructor<const int*, true>();
|
|
|
|
test_has_copy_constructor<NotEmpty, true>();
|
|
|
|
test_has_copy_constructor<bit_zero, true>();
|
2010-05-11 21:42:16 +02:00
|
|
|
}
|