Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:45:56

0001 /* Copyright 2024 Joaquin M Lopez Munoz.
0002  * Distributed under the Boost Software License, Version 1.0.
0003  * (See accompanying file LICENSE_1_0.txt or copy at
0004  * http://www.boost.org/LICENSE_1_0.txt)
0005  *
0006  * See http://www.boost.org/libs/poly_collection for library home page.
0007  */
0008 
0009 #ifndef BOOST_POLY_COLLECTION_DETAIL_COPYABLE_HPP
0010 #define BOOST_POLY_COLLECTION_DETAIL_COPYABLE_HPP
0011 
0012 #if defined(_MSC_VER)
0013 #pragma once
0014 #endif
0015 
0016 #include <functional>
0017 #include <type_traits>
0018 
0019 namespace boost{
0020 
0021 namespace poly_collection{
0022 
0023 namespace detail{
0024 
0025 /* wraps T if it is not copyable */
0026 
0027 template<typename T,typename=void>
0028 struct copyable_impl{using type=T;};
0029 
0030 template<typename T>
0031 struct reference_wrapper
0032 {
0033   reference_wrapper(T& x):p{&x}{}
0034 
0035   operator T&()const noexcept{return *p;}
0036 
0037   T* p;
0038 };
0039 
0040 template<typename T>
0041 struct copyable_impl<
0042   T,
0043   typename std::enable_if<!std::is_copy_constructible<T>::value>::type
0044 >
0045 {using type=reference_wrapper<const T>;};
0046 
0047 template<typename T>
0048 using copyable=typename copyable_impl<T>::type;
0049 
0050 template<typename T>
0051 copyable<T> make_copyable(const T& x){return x;}
0052 
0053 } /* namespace poly_collection::detail */
0054 
0055 } /* namespace poly_collection */
0056 
0057 } /* namespace boost */
0058 
0059 #endif