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_CONSTRUCTOR_HPP_INCLUDED
10#define BOOST_TT_HAS_TRIVIAL_CONSTRUCTOR_HPP_INCLUDED
11
12#include <boost/type_traits/intrinsics.hpp>
13#include <boost/type_traits/is_pod.hpp>
14#include <boost/type_traits/is_default_constructible.hpp>
15
16#ifdef BOOST_HAS_TRIVIAL_CONSTRUCTOR
17#ifdef BOOST_HAS_SGI_TYPE_TRAITS
18#include <boost/type_traits/is_same.hpp>
19#elif defined(__GNUC__) || defined(__SUNPRO_CC)
20#include <boost/type_traits/is_volatile.hpp>
21#ifdef BOOST_INTEL
22#include <boost/type_traits/is_pod.hpp>
23#endif
24#endif
25#endif
26
27
28#if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)) || defined(BOOST_CLANG) || (defined(__SUNPRO_CC) && defined(BOOST_HAS_TRIVIAL_CONSTRUCTOR))
29#include <boost/type_traits/is_default_constructible.hpp>
30#define BOOST_TT_TRIVIAL_CONSTRUCT_FIX && is_default_constructible<T>::value
31#else
32//
33// Mot all compilers, particularly older GCC versions can handle the fix above.
34#define BOOST_TT_TRIVIAL_CONSTRUCT_FIX
35#endif
36
37namespace boost {
38
39template <typename T> struct has_trivial_constructor
40#ifdef BOOST_HAS_TRIVIAL_CONSTRUCTOR
41 : public integral_constant <bool, ((::boost::is_pod<T>::value || BOOST_HAS_TRIVIAL_CONSTRUCTOR(T)) BOOST_TT_TRIVIAL_CONSTRUCT_FIX)>{};
42#else
43 : public integral_constant <bool, ::boost::is_pod<T>::value>{};
44#endif
45
46template <> struct has_trivial_constructor<void> : public boost::false_type{};
47template <> struct has_trivial_constructor<void const> : public boost::false_type{};
48template <> struct has_trivial_constructor<void const volatile> : public boost::false_type{};
49template <> struct has_trivial_constructor<void volatile> : public boost::false_type{};
50
51template <class T> struct has_trivial_default_constructor : public has_trivial_constructor<T> {};
52
53#undef BOOST_TT_TRIVIAL_CONSTRUCT_FIX
54
55} // namespace boost
56
57#endif // BOOST_TT_HAS_TRIVIAL_CONSTRUCTOR_HPP_INCLUDED
58

source code of boost/boost/type_traits/has_trivial_constructor.hpp