Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:10

0001 
0002 //  (C) Copyright John Maddock 2015.
0003 //  Use, modification and distribution are subject to the Boost Software License,
0004 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0005 //  http://www.boost.org/LICENSE_1_0.txt).
0006 //
0007 //  See http://www.boost.org/libs/type_traits for most recent version including documentation.
0008 
0009 #ifndef BOOST_TT_IS_ASSIGNABLE_HPP_INCLUDED
0010 #define BOOST_TT_IS_ASSIGNABLE_HPP_INCLUDED
0011 
0012 #include <cstddef> // size_t
0013 #include <boost/type_traits/integral_constant.hpp>
0014 #include <boost/detail/workaround.hpp>
0015 #include <boost/type_traits/is_complete.hpp>
0016 #include <boost/static_assert.hpp>
0017 
0018 namespace boost{
0019 
0020    template <class T, class U = T> struct is_assignable;
0021 
0022 }
0023 
0024 #if !defined(BOOST_NO_CXX11_DECLTYPE) && !BOOST_WORKAROUND(BOOST_MSVC, < 1800)
0025 
0026 #include <boost/type_traits/detail/yes_no_type.hpp>
0027 #include <boost/type_traits/declval.hpp>
0028 
0029 namespace boost{
0030 
0031    namespace detail{
0032 
0033       struct is_assignable_imp
0034       {
0035          template<typename T, typename U, typename = decltype(boost::declval<T>() = boost::declval<U>())>
0036          static boost::type_traits::yes_type test(int);
0037 
0038          template<typename, typename>
0039          static boost::type_traits::no_type test(...);
0040       };
0041 
0042    }
0043 
0044    template <class T, class U> struct is_assignable : public integral_constant<bool, sizeof(detail::is_assignable_imp::test<T, U>(0)) == sizeof(boost::type_traits::yes_type)>
0045    {
0046       BOOST_STATIC_ASSERT_MSG(boost::is_complete<T>::value, "Arguments to is_assignable must be complete types");
0047    };
0048    template <class T, std::size_t N, class U> struct is_assignable<T[N], U> : public is_assignable<T, U>{};
0049    template <class T, std::size_t N, class U> struct is_assignable<T(&)[N], U> : public is_assignable<T&, U>{};
0050    template <class T, class U> struct is_assignable<T[], U> : public is_assignable<T, U>{};
0051    template <class T, class U> struct is_assignable<T(&)[], U> : public is_assignable<T&, U>{};
0052    template <class U> struct is_assignable<void, U> : public integral_constant<bool, false>{};
0053    template <class U> struct is_assignable<void const, U> : public integral_constant<bool, false>{};
0054    template <class U> struct is_assignable<void volatile, U> : public integral_constant<bool, false>{};
0055    template <class U> struct is_assignable<void const volatile, U> : public integral_constant<bool, false>{};
0056 
0057 #else
0058 
0059 #include <boost/type_traits/has_trivial_assign.hpp>
0060 #include <boost/type_traits/remove_reference.hpp>
0061 
0062 namespace boost{
0063 
0064    // We don't know how to implement this:
0065    template <class T, class U> struct is_assignable : public integral_constant<bool, false>
0066    {
0067       BOOST_STATIC_ASSERT_MSG(boost::is_complete<T>::value, "Arguments to is_assignable must be complete types");
0068    };
0069    template <class T, class U> struct is_assignable<T&, U> : public integral_constant<bool, is_pod<T>::value && is_pod<typename remove_reference<U>::type>::value>{};
0070    template <class T, class U> struct is_assignable<const T&, U> : public integral_constant<bool, false>{};
0071    template <class U> struct is_assignable<void, U> : public integral_constant<bool, false>{};
0072    template <class U> struct is_assignable<void const, U> : public integral_constant<bool, false>{};
0073    template <class U> struct is_assignable<void volatile, U> : public integral_constant<bool, false>{};
0074    template <class U> struct is_assignable<void const volatile, U> : public integral_constant<bool, false>{};
0075    /*
0076    template <> struct is_assignable<void, void> : public integral_constant<bool, false>{};
0077    template <> struct is_assignable<void const, void const> : public integral_constant<bool, false>{};
0078    template <> struct is_assignable<void volatile, void volatile> : public integral_constant<bool, false>{};
0079    template <> struct is_assignable<void const volatile, void const volatile> : public integral_constant<bool, false>{};
0080    */
0081 #endif
0082 
0083 } // namespace boost
0084 
0085 #endif // BOOST_TT_IS_ASSIGNABLE_HPP_INCLUDED