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).
7 // See http://www.boost.org/libs/type_traits for most recent version including documentation.
9 #ifndef BOOST_TT_HAS_TRIVIAL_CONSTRUCTOR_HPP_INCLUDED
10 #define BOOST_TT_HAS_TRIVIAL_CONSTRUCTOR_HPP_INCLUDED
12 #include <boost/type_traits/intrinsics.hpp>
13 #include <boost/type_traits/is_pod.hpp>
14 #include <boost/type_traits/is_default_constructible.hpp>
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>
22 #include <boost/type_traits/is_pod.hpp>
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
33 // Mot all compilers, particularly older GCC versions can handle the fix above.
34 #define BOOST_TT_TRIVIAL_CONSTRUCT_FIX
39 template <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)>{};
43 : public integral_constant <bool, ::boost::is_pod<T>::value>{};
46 template <> struct has_trivial_constructor<void> : public boost::false_type{};
47 template <> struct has_trivial_constructor<void const> : public boost::false_type{};
48 template <> struct has_trivial_constructor<void const volatile> : public boost::false_type{};
49 template <> struct has_trivial_constructor<void volatile> : public boost::false_type{};
51 template <class T> struct has_trivial_default_constructor : public has_trivial_constructor<T> {};
53 #undef BOOST_TT_TRIVIAL_CONSTRUCT_FIX
57 #endif // BOOST_TT_HAS_TRIVIAL_CONSTRUCTOR_HPP_INCLUDED