Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 08:44:21

0001 /*
0002  * Distributed under the Boost Software License, Version 1.0.
0003  * (See accompanying file LICENSE_1_0.txt or copy at
0004  * https://www.boost.org/LICENSE_1_0.txt)
0005  *
0006  * Copyright (c) 2022 Andrey Semashev
0007  */
0008 /*!
0009  * \file scope/detail/move_or_copy_assign_ref.hpp
0010  *
0011  * This header contains definition of \c move_or_copy_assign_ref type trait.
0012  */
0013 
0014 #ifndef BOOST_SCOPE_DETAIL_MOVE_OR_COPY_ASSIGN_REF_HPP_INCLUDED_
0015 #define BOOST_SCOPE_DETAIL_MOVE_OR_COPY_ASSIGN_REF_HPP_INCLUDED_
0016 
0017 #include <type_traits>
0018 #include <boost/scope/detail/config.hpp>
0019 #include <boost/scope/detail/header.hpp>
0020 
0021 #ifdef BOOST_HAS_PRAGMA_ONCE
0022 #pragma once
0023 #endif
0024 
0025 namespace boost {
0026 namespace scope {
0027 namespace detail {
0028 
0029 //! The type trait produces an rvalue reference to \a From if \a To has a non-throwing assignment from a \a From rvalue and an lvalue reference otherwise.
0030 template< typename From, typename To = From >
0031 struct move_or_copy_assign_ref
0032 {
0033     using type = typename std::conditional<
0034         std::is_nothrow_assignable< To, From >::value,
0035         From&&,
0036         From const&
0037     >::type;
0038 };
0039 
0040 template< typename From, typename To >
0041 struct move_or_copy_assign_ref< From&, To >
0042 {
0043     using type = From&;
0044 };
0045 
0046 } // namespace detail
0047 } // namespace scope
0048 } // namespace boost
0049 
0050 #include <boost/scope/detail/footer.hpp>
0051 
0052 #endif // BOOST_SCOPE_DETAIL_MOVE_OR_COPY_ASSIGN_REF_HPP_INCLUDED_