2010-08-22 02:59:46 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
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-08-22 02:59:46 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// type_traits
|
|
|
|
|
|
|
|
// alignment_of
|
|
|
|
|
|
|
|
#include <type_traits>
|
2013-07-15 20:09:11 +02:00
|
|
|
#include <cstdint>
|
2010-08-22 02:59:46 +02:00
|
|
|
|
|
|
|
template <class T, unsigned A>
|
|
|
|
void test_alignment_of()
|
|
|
|
{
|
|
|
|
static_assert( std::alignment_of<T>::value == A, "");
|
|
|
|
static_assert( std::alignment_of<const T>::value == A, "");
|
|
|
|
static_assert( std::alignment_of<volatile T>::value == A, "");
|
|
|
|
static_assert( std::alignment_of<const volatile T>::value == A, "");
|
|
|
|
}
|
|
|
|
|
|
|
|
class Class
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~Class();
|
|
|
|
};
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2013-04-22 21:37:49 +02:00
|
|
|
test_alignment_of<int&, 4>();
|
2010-08-22 02:59:46 +02:00
|
|
|
test_alignment_of<Class, 1>();
|
2013-07-15 20:09:11 +02:00
|
|
|
test_alignment_of<int*, sizeof(intptr_t)>();
|
|
|
|
test_alignment_of<const int*, sizeof(intptr_t)>();
|
2010-08-22 02:59:46 +02:00
|
|
|
test_alignment_of<char[3], 1>();
|
|
|
|
test_alignment_of<int, 4>();
|
2013-04-22 21:37:49 +02:00
|
|
|
test_alignment_of<double, 8>();
|
2010-08-22 02:59:46 +02:00
|
|
|
test_alignment_of<bool, 1>();
|
|
|
|
test_alignment_of<unsigned, 4>();
|
|
|
|
}
|