1
2// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
3// Use, modification and distribution are subject to the Boost Software License,
4// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5// http://www.boost.org/LICENSE_1_0.txt).
6//
7// See http://www.boost.org/libs/type_traits for most recent version including documentation.
8
9#ifndef BOOST_TT_HAS_TRIVIAL_COPY_HPP_INCLUDED
10#define BOOST_TT_HAS_TRIVIAL_COPY_HPP_INCLUDED
11
12#include <cstddef> // size_t
13#include <boost/type_traits/intrinsics.hpp>
14#include <boost/type_traits/is_pod.hpp>
15#include <boost/type_traits/is_reference.hpp>
16
17#if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)) || defined(BOOST_CLANG) || (defined(__SUNPRO_CC) && defined(BOOST_HAS_TRIVIAL_COPY))
18#include <boost/type_traits/is_copy_constructible.hpp>
19#define BOOST_TT_TRIVIAL_CONSTRUCT_FIX && is_copy_constructible<T>::value
20#else
21#define BOOST_TT_TRIVIAL_CONSTRUCT_FIX
22#endif
23
24#ifdef BOOST_INTEL
25#include <boost/type_traits/add_const.hpp>
26#include <boost/type_traits/add_lvalue_reference.hpp>
27#endif
28
29namespace boost {
30
31template <typename T> struct has_trivial_copy
32: public integral_constant<bool,
33#ifdef BOOST_HAS_TRIVIAL_COPY
34 BOOST_HAS_TRIVIAL_COPY(T) BOOST_TT_TRIVIAL_CONSTRUCT_FIX
35#else
36 ::boost::is_pod<T>::value
37#endif
38>{};
39// Arrays are not explicitly copyable:
40template <typename T, std::size_t N> struct has_trivial_copy<T[N]> : public false_type{};
41template <typename T> struct has_trivial_copy<T[]> : public false_type{};
42// Are volatile types ever trivial? We don't really know, so assume not:
43template <typename T> struct has_trivial_copy<T volatile> : public false_type{};
44
45template <> struct has_trivial_copy<void> : public false_type{};
46#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
47template <> struct has_trivial_copy<void const> : public false_type{};
48template <> struct has_trivial_copy<void volatile> : public false_type{};
49template <> struct has_trivial_copy<void const volatile> : public false_type{};
50#endif
51
52template <class T> struct has_trivial_copy<T&> : public false_type{};
53#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
54template <class T> struct has_trivial_copy<T&&> : public false_type{};
55#endif
56
57template <class T> struct has_trivial_copy_constructor : public has_trivial_copy<T>{};
58
59#undef BOOST_TT_TRIVIAL_CONSTRUCT_FIX
60
61} // namespace boost
62
63#endif // BOOST_TT_HAS_TRIVIAL_COPY_HPP_INCLUDED
64

source code of include/boost/type_traits/has_trivial_copy.hpp