// Boost.TypeErasure library // // Copyright 2011 Steven Watanabe // // 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) // // $Id: storage.hpp 83253 2013-03-02 21:48:27Z steven_watanabe $ #ifndef BOOST_TYPE_ERASURE_DETAIL_STORAGE_HPP_INCLUDED #define BOOST_TYPE_ERASURE_DETAIL_STORAGE_HPP_INCLUDED #include namespace boost { namespace type_erasure { namespace detail { struct storage { storage() {} template storage(const T& arg) : data(new T(arg)) {} void* data; }; #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template T extract(T arg) { return std::forward(arg); } #else template T extract(T arg) { return arg; } #endif template T extract(storage& arg) { return *static_cast::type*>(arg.data); } template T extract(const storage& arg) { return *static_cast::type*>(arg.data); } #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template T extract(storage&& arg) { return std::move(*static_cast::type*>(arg.data)); } #endif } } } #endif