/* Copyright 2024 Joaquin M Lopez Munoz. * Distributed under 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/poly_collection for library home page. */ #ifndef BOOST_POLY_COLLECTION_DETAIL_COPYABLE_HPP #define BOOST_POLY_COLLECTION_DETAIL_COPYABLE_HPP #if defined(_MSC_VER) #pragma once #endif #include #include namespace boost{ namespace poly_collection{ namespace detail{ /* wraps T if it is not copyable */ template struct copyable_impl{using type=T;}; template struct reference_wrapper { reference_wrapper(T& x):p{&x}{} operator T&()const noexcept{return *p;} T* p; }; template struct copyable_impl< T, typename std::enable_if::value>::type > {using type=reference_wrapper;}; template using copyable=typename copyable_impl::type; template copyable make_copyable(const T& x){return x;} } /* namespace poly_collection::detail */ } /* namespace poly_collection */ } /* namespace boost */ #endif