diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:12:59 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:12:59 +0900 |
commit | b8cf34c691623e4ec329053cbbf68522a855882d (patch) | |
tree | 34da08632a99677f6b79ecb65e5b655a5b69a67f /boost/type_traits/is_complete.hpp | |
parent | 3fdc3e5ee96dca5b11d1694975a65200787eab86 (diff) | |
download | boost-b8cf34c691623e4ec329053cbbf68522a855882d.tar.gz boost-b8cf34c691623e4ec329053cbbf68522a855882d.tar.bz2 boost-b8cf34c691623e4ec329053cbbf68522a855882d.zip |
Imported Upstream version 1.67.0upstream/1.67.0
Diffstat (limited to 'boost/type_traits/is_complete.hpp')
-rw-r--r-- | boost/type_traits/is_complete.hpp | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/boost/type_traits/is_complete.hpp b/boost/type_traits/is_complete.hpp new file mode 100644 index 0000000000..fe5e338c74 --- /dev/null +++ b/boost/type_traits/is_complete.hpp @@ -0,0 +1,90 @@ + +// (C) Copyright John Maddock 2017. +// Use, modification and distribution are subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt). +// +// See http://www.boost.org/libs/type_traits for most recent version including documentation. + +#ifndef BOOST_TT_IS_COMPLETE_HPP_INCLUDED +#define BOOST_TT_IS_COMPLETE_HPP_INCLUDED + +#include <boost/type_traits/integral_constant.hpp> +#include <boost/type_traits/remove_reference.hpp> +#include <boost/type_traits/is_function.hpp> +#include <boost/config/workaround.hpp> + +/* + * CAUTION: + * ~~~~~~~~ + * + * THIS TRAIT EXISTS SOLELY TO GENERATE HARD ERRORS WHEN A ANOTHER TRAIT + * WHICH REQUIRES COMPLETE TYPES AS ARGUMENTS IS PASSED AN INCOMPLETE TYPE + * + * DO NOT MAKE GENERAL USE OF THIS TRAIT, AS THE COMPLETENESS OF A TYPE + * VARIES ACROSS TRANSLATION UNITS AS WELL AS WITHIN A SINGLE UNIT. + * +*/ + +namespace boost { + + +// +// We will undef this if the trait isn't fully functional: +// +#define BOOST_TT_HAS_WORKING_IS_COMPLETE + +#if !defined(BOOST_NO_SFINAE_EXPR) && !BOOST_WORKAROUND(BOOST_MSVC, <= 1900) && !BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40600) + + namespace detail{ + + template <unsigned N> + struct ok_tag { double d; char c[N]; }; + + template <class T> + ok_tag<sizeof(T)> check_is_complete(int); + template <class T> + char check_is_complete(...); + } + + template <class T> struct is_complete + : public integral_constant<bool, ::boost::is_function<typename boost::remove_reference<T>::type>::value || (sizeof(detail::check_is_complete<T>(0)) != sizeof(char))> {}; + +#elif !defined(BOOST_NO_SFINAE) && !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS) && !BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40500) + + namespace detail + { + + template <class T> + struct is_complete_imp + { + template <class U, class = decltype(sizeof(std::declval< U >())) > + static type_traits::yes_type check(U*); + + template <class U> + static type_traits::no_type check(...); + + static const bool value = sizeof(check<T>(0)) == sizeof(type_traits::yes_type); + }; + +} // namespace detail + + + template <class T> + struct is_complete : boost::integral_constant<bool, ::boost::is_function<typename boost::remove_reference<T>::type>::value || ::boost::detail::is_complete_imp<T>::value> + {}; + template <class T> + struct is_complete<T&> : boost::is_complete<T> {}; + +#else + + template <class T> struct is_complete + : public boost::integral_constant<bool, true> {}; + +#undef BOOST_TT_HAS_WORKING_IS_COMPLETE + +#endif + +} // namespace boost + +#endif // BOOST_TT_IS_COMPLETE_HPP_INCLUDED |