[DEV] add v1.66.0

This commit is contained in:
2018-01-12 21:47:58 +01:00
parent 87059bb1af
commit a97e9ae7d4
49032 changed files with 7668950 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
# Copyright 2014-2015 Glen Joseph Fernandes
# (glenjofe@gmail.com)
#
# Distributed under the Boost Software License, Version 1.0.
# (http://www.boost.org/LICENSE_1_0.txt)
import testing ;
run align_test.cpp ;
run align_down_test.cpp ;
run align_up_test.cpp ;
run aligned_alloc_test.cpp ;
run aligned_allocator_test.cpp ;
run aligned_allocator_adaptor_test.cpp ;
run aligned_delete_test.cpp ;
run alignment_of_test.cpp ;
run assume_aligned_test.cpp ;
run is_aligned_test.cpp ;

View File

@@ -0,0 +1,43 @@
/*
Copyright 2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/align/align_down.hpp>
#include <boost/align/is_aligned.hpp>
#include <boost/core/lightweight_test.hpp>
template<std::size_t Alignment>
void test()
{
char s[Alignment << 1];
char* b = s;
while (!boost::alignment::is_aligned(b, Alignment)) {
++b;
}
{
void* p = &b[Alignment];
BOOST_TEST(boost::alignment::align_down(p, Alignment) == p);
}
{
void* p = &b[Alignment - 1];
void* q = b;
BOOST_TEST(boost::alignment::align_down(p, Alignment) == q);
}
}
int main()
{
test<1>();
test<2>();
test<4>();
test<8>();
test<16>();
test<32>();
test<64>();
test<128>();
return boost::report_errors();
}

View File

@@ -0,0 +1,68 @@
/*
Copyright 2014-2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/align/align.hpp>
#include <boost/align/is_aligned.hpp>
#include <boost/core/lightweight_test.hpp>
template<std::size_t Alignment>
void test()
{
char s[Alignment << 1];
char* b = s;
while (!boost::alignment::is_aligned(b, Alignment)) {
++b;
}
{
std::size_t n = Alignment;
void* p = b;
void* q = boost::alignment::align(Alignment, 1, p, n);
BOOST_TEST(q == p);
BOOST_TEST(q == b);
BOOST_TEST(boost::alignment::is_aligned(q, Alignment));
BOOST_TEST(n == Alignment);
}
{
std::size_t n = 0;
void* p = b;
void* q = boost::alignment::align(Alignment, 1, p, n);
BOOST_TEST(q == 0);
BOOST_TEST(p == b);
BOOST_TEST(n == 0);
}
{
std::size_t n = Alignment - 1;
void* p = &b[1];
void* q = boost::alignment::align(Alignment, 1, p, n);
BOOST_TEST(q == 0);
BOOST_TEST(p == &b[1]);
BOOST_TEST(n == Alignment - 1);
}
{
std::size_t n = Alignment;
void* p = &b[1];
void* q = boost::alignment::align(Alignment, 1, p, n);
BOOST_TEST(q == p);
BOOST_TEST(p == &b[Alignment]);
BOOST_TEST(boost::alignment::is_aligned(q, Alignment));
BOOST_TEST(n == 1);
}
}
int main()
{
test<1>();
test<2>();
test<4>();
test<8>();
test<16>();
test<32>();
test<64>();
test<128>();
return boost::report_errors();
}

View File

@@ -0,0 +1,43 @@
/*
Copyright 2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/align/align_up.hpp>
#include <boost/align/is_aligned.hpp>
#include <boost/core/lightweight_test.hpp>
template<std::size_t Alignment>
void test()
{
char s[Alignment << 1];
char* b = s;
while (!boost::alignment::is_aligned(b, Alignment)) {
++b;
}
{
void* p = b;
BOOST_TEST(boost::alignment::align_up(p, Alignment) == p);
}
{
void* p = &b[Alignment];
void* q = &b[1];
BOOST_TEST(boost::alignment::align_up(q, Alignment) == p);
}
}
int main()
{
test<1>();
test<2>();
test<4>();
test<8>();
test<16>();
test<32>();
test<64>();
test<128>();
return boost::report_errors();
}

View File

@@ -0,0 +1,47 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/align/aligned_alloc.hpp>
#include <boost/align/is_aligned.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstring>
void test(std::size_t alignment)
{
{
void* p = boost::alignment::aligned_alloc(alignment, alignment + 1);
BOOST_TEST(p != 0);
BOOST_TEST(boost::alignment::is_aligned(p, alignment));
std::memset(p, 0, alignment);
boost::alignment::aligned_free(p);
}
{
void* p = boost::alignment::aligned_alloc(alignment, 1);
BOOST_TEST(p != 0);
BOOST_TEST(boost::alignment::is_aligned(p, alignment));
std::memset(p, 0, 1);
boost::alignment::aligned_free(p);
}
{
void* p = boost::alignment::aligned_alloc(alignment, 0);
boost::alignment::aligned_free(p);
}
}
int main()
{
test(1);
test(2);
test(4);
test(8);
test(16);
test(32);
test(64);
test(128);
return boost::report_errors();
}

View File

@@ -0,0 +1,156 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/align/aligned_allocator_adaptor.hpp>
#include <boost/align/is_aligned.hpp>
#include <boost/core/lightweight_test.hpp>
#include <new>
#include <cstring>
template<class T>
class A {
public:
typedef T value_type;
typedef T* pointer;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
template<class U>
struct rebind {
typedef A<U> other;
};
A(int state)
: state_(state) { }
template<class U>
A(const A<U>& other)
: state_(other.state()) { }
T* allocate(std::size_t size, const void* = 0) {
return static_cast<T*>(::operator new(sizeof(T) * size));
}
void deallocate(T* ptr, std::size_t) {
::operator delete(ptr);
}
void construct(T* ptr, const T& value) {
::new(static_cast<void*>(ptr)) T(value);
}
void destroy(T* ptr) {
ptr->~T();
}
int state() const {
return state_;
}
private:
int state_;
};
template<class T, class U>
inline bool
operator==(const A<T>& a, const A<U>& b)
{
return a.state() == b.state();
}
template<class T, class U>
inline bool
operator!=(const A<T>& a, const A<U>& b)
{
return !(a == b);
}
template<std::size_t Alignment>
void test_allocate()
{
{
boost::alignment::aligned_allocator_adaptor<A<int>, Alignment> a(5);
int* p = a.allocate(1);
BOOST_TEST(p != 0);
BOOST_TEST(boost::alignment::is_aligned(p, Alignment));
std::memset(p, 0, 1);
a.deallocate(p, 1);
}
{
boost::alignment::aligned_allocator_adaptor<A<int>, Alignment> a(5);
int* p = a.allocate(1);
int* q = a.allocate(1, p);
BOOST_TEST(q != 0);
BOOST_TEST(boost::alignment::is_aligned(q, Alignment));
std::memset(q, 0, 1);
a.deallocate(q, 1);
a.deallocate(p, 1);
}
{
boost::alignment::aligned_allocator_adaptor<A<int>, Alignment> a(5);
int* p = a.allocate(0);
a.deallocate(p, 0);
}
}
template<std::size_t Alignment>
void test_construct()
{
boost::alignment::aligned_allocator_adaptor<A<int>, Alignment> a(5);
int* p = a.allocate(1);
a.construct(p, 1);
BOOST_TEST(*p == 1);
a.destroy(p);
a.deallocate(p, 1);
}
template<std::size_t Alignment>
void test_constructor()
{
{
boost::alignment::aligned_allocator_adaptor<A<char>, Alignment> a(5);
boost::alignment::aligned_allocator_adaptor<A<int>, Alignment> b(a);
BOOST_TEST(b == a);
}
{
A<int> a(5);
boost::alignment::aligned_allocator_adaptor<A<int>, Alignment> b(a);
BOOST_TEST(b.base() == a);
}
}
template<std::size_t Alignment>
void test_rebind()
{
boost::alignment::aligned_allocator_adaptor<A<int>, Alignment> a(5);
typename boost::alignment::aligned_allocator_adaptor<A<int>,
Alignment>::template rebind<int>::other b(a);
BOOST_TEST(b == a);
}
template<std::size_t Alignment>
void test()
{
test_allocate<Alignment>();
test_construct<Alignment>();
test_constructor<Alignment>();
test_rebind<Alignment>();
}
int main()
{
test<1>();
test<2>();
test<4>();
test<8>();
test<16>();
test<32>();
test<64>();
test<128>();
return boost::report_errors();
}

View File

@@ -0,0 +1,80 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/align/aligned_allocator.hpp>
#include <boost/align/is_aligned.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstring>
template<std::size_t Alignment>
void test_allocate()
{
{
boost::alignment::aligned_allocator<int, Alignment> a;
int* p = a.allocate(1);
BOOST_TEST(p != 0);
BOOST_TEST(boost::alignment::is_aligned(p, Alignment));
std::memset(p, 0, 1);
a.deallocate(p, 1);
}
{
boost::alignment::aligned_allocator<int, Alignment> a;
int* p = a.allocate(0);
a.deallocate(p, 0);
}
}
template<std::size_t Alignment>
void test_construct()
{
boost::alignment::aligned_allocator<int, Alignment> a;
int* p = a.allocate(1);
a.construct(p, 1);
BOOST_TEST(*p == 1);
a.destroy(p);
a.deallocate(p, 1);
}
template<std::size_t Alignment>
void test_constructor()
{
boost::alignment::aligned_allocator<char, Alignment> a1;
boost::alignment::aligned_allocator<int, Alignment> a2(a1);
BOOST_TEST(a2 == a1);
}
template<std::size_t Alignment>
void test_rebind()
{
boost::alignment::aligned_allocator<char, Alignment> a1;
typename boost::alignment::aligned_allocator<char,
Alignment>::template rebind<int>::other a2(a1);
BOOST_TEST(a2 == a1);
}
template<std::size_t Alignment>
void test()
{
test_allocate<Alignment>();
test_construct<Alignment>();
test_constructor<Alignment>();
test_rebind<Alignment>();
}
int main()
{
test<1>();
test<2>();
test<4>();
test<8>();
test<16>();
test<32>();
test<64>();
test<128>();
return boost::report_errors();
}

View File

@@ -0,0 +1,51 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/align/aligned_alloc.hpp>
#include <boost/align/aligned_delete.hpp>
#include <boost/align/alignment_of.hpp>
#include <boost/core/lightweight_test.hpp>
#include <new>
class type {
public:
static unsigned count;
type() {
++count;
}
~type() {
--count;
}
private:
type(const type&);
type& operator=(const type&);
};
unsigned type::count = 0;
int main()
{
{
void* p = boost::alignment::aligned_alloc(1, 1);
char* q = ::new(p) char;
boost::alignment::aligned_delete()(q);
}
{
enum {
N = boost::alignment::alignment_of<type>::value
};
void* p = boost::alignment::aligned_alloc(N, sizeof(type));
type* q = ::new(p) type;
BOOST_TEST(type::count == 1);
boost::alignment::aligned_delete()(q);
BOOST_TEST(type::count == 0);
}
return boost::report_errors();
}

View File

@@ -0,0 +1,219 @@
/*
Copyright 2014 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/align/alignment_of.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <cstddef>
template<class T>
struct remove_reference {
typedef T type;
};
template<class T>
struct remove_reference<T&> {
typedef T type;
};
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template<class T>
struct remove_reference<T&&> {
typedef T type;
};
#endif
template<class T>
struct remove_all_extents {
typedef T type;
};
template<class T>
struct remove_all_extents<T[]> {
typedef typename remove_all_extents<T>::type type;
};
template<class T, std::size_t N>
struct remove_all_extents<T[N]> {
typedef typename remove_all_extents<T>::type type;
};
template<class T>
struct remove_cv {
typedef T type;
};
template<class T>
struct remove_cv<const T> {
typedef T type;
};
template<class T>
struct remove_cv<volatile T> {
typedef T type;
};
template<class T>
struct remove_cv<const volatile T> {
typedef T type;
};
template<class T>
struct offset_value {
char value;
typename remove_cv<typename remove_all_extents<typename
remove_reference<T>::type>::type>::type object;
};
template<class T>
void test_type()
{
enum {
N = boost::alignment::alignment_of<T>::value
};
BOOST_TEST(offsetof(offset_value<T>, object) == N);
}
template<class T>
void test_reference()
{
test_type<T>();
test_type<T&>();
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
test_type<T&&>();
#endif
}
template<class T>
void test_array()
{
test_reference<T>();
test_reference<T[2]>();
test_type<T[]>();
}
template<class T>
void test_cv()
{
test_array<T>();
test_array<const T>();
test_array<volatile T>();
test_array<const volatile T>();
}
template<class T>
struct Struct {
T t;
};
template<class T>
union Union {
T t;
};
template<class T>
void test()
{
test_cv<T>();
test_cv<Struct<T> >();
test_cv<Union<T> >();
}
void test_integral()
{
test<bool>();
test<char>();
test<signed char>();
test<unsigned char>();
test<wchar_t>();
#if !defined(BOOST_NO_CXX11_CHAR16_T)
test<char16_t>();
#endif
#if !defined(BOOST_NO_CXX11_CHAR32_T)
test<char32_t>();
#endif
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
#if !defined(BOOST_NO_LONG_LONG)
test<long long>();
test<unsigned long long>();
#endif
}
void test_floating_point()
{
test<float>();
test<double>();
test<long double>();
}
void test_nullptr_t()
{
#if !defined(BOOST_NO_CXX11_NULLPTR) && \
!defined(BOOST_NO_CXX11_DECLTYPE)
test<decltype(nullptr)>();
#endif
}
class X;
void test_pointer()
{
test<void*>();
test<char*>();
test<int*>();
test<X*>();
test<void(*)()>();
}
void test_member_pointer()
{
test<int X::*>();
test<int(X::*)()>();
}
enum E {
V = 1
};
void test_enum()
{
test<E>();
}
struct S { };
class C { };
union U { };
void test_class()
{
test<S>();
test<C>();
test<U>();
}
int main()
{
test_integral();
test_floating_point();
test_nullptr_t();
test_pointer();
test_member_pointer();
test_enum();
test_class();
return boost::report_errors();
}

View File

@@ -0,0 +1,61 @@
/*
Copyright 2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/align/assume_aligned.hpp>
void* test1(void* p)
{
BOOST_ALIGN_ASSUME_ALIGNED(p, 1);
return p;
}
void* test2(void* p)
{
BOOST_ALIGN_ASSUME_ALIGNED(p, 2);
return p;
}
void* test4(void* p)
{
BOOST_ALIGN_ASSUME_ALIGNED(p, 4);
return p;
}
void* test8(void* p)
{
BOOST_ALIGN_ASSUME_ALIGNED(p, 8);
return p;
}
void* test16(void* p)
{
BOOST_ALIGN_ASSUME_ALIGNED(p, 16);
return p;
}
void* test32(void* p)
{
BOOST_ALIGN_ASSUME_ALIGNED(p, 32);
return p;
}
void* test64(void* p)
{
BOOST_ALIGN_ASSUME_ALIGNED(p, 64);
return p;
}
void* test128(void* p)
{
BOOST_ALIGN_ASSUME_ALIGNED(p, 128);
return p;
}
int main()
{
return 0;
}

View File

@@ -0,0 +1,71 @@
/*
Copyright 2014-2015 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/align/alignment_of.hpp>
#include <boost/align/is_aligned.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
template<std::size_t N>
struct A { };
template<std::size_t N>
void test(char* p, A<N>)
{
BOOST_TEST(boost::alignment::is_aligned(p, N));
BOOST_TEST(!boost::alignment::is_aligned(p + 1, N));
}
void test(char* p, A<1>)
{
BOOST_TEST(boost::alignment::is_aligned(p, 1));
}
template<class T>
void test()
{
T o;
test(reinterpret_cast<char*>(&o),
A<boost::alignment::alignment_of<T>::value>());
}
class X;
int main()
{
test<bool>();
test<char>();
test<wchar_t>();
#if !defined(BOOST_NO_CXX11_CHAR16_T)
test<char16_t>();
#endif
#if !defined(BOOST_NO_CXX11_CHAR32_T)
test<char32_t>();
#endif
test<short>();
test<int>();
test<long>();
#if !defined(BOOST_NO_LONG_LONG) && !defined(_MSC_VER)
test<long long>();
#endif
test<float>();
#if !defined(BOOST_MSVC)
test<double>();
test<long double>();
#endif
test<void*>();
test<char*>();
test<int*>();
test<X*>();
test<void(*)()>();
#if !defined(BOOST_MSVC)
test<int X::*>();
test<int(X::*)()>();
#endif
return boost::report_errors();
}