123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- #ifndef BOOST_MOVE_MAKE_UNIQUE_HPP_INCLUDED
- #define BOOST_MOVE_MAKE_UNIQUE_HPP_INCLUDED
- #ifndef BOOST_CONFIG_HPP
- # include <boost/config.hpp>
- #endif
- #
- #if defined(BOOST_HAS_PRAGMA_ONCE)
- # pragma once
- #endif
- #include <boost/move/detail/config_begin.hpp>
- #include <boost/move/detail/workaround.hpp>
- #include <boost/move/utility_core.hpp>
- #include <boost/move/unique_ptr.hpp>
- #include <cstddef> //for std::size_t
- #include <boost/move/detail/unique_ptr_meta_utils.hpp>
- #ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES
- # include <boost/move/detail/fwd_macros.hpp>
- #endif
-
- #if !defined(BOOST_MOVE_DOXYGEN_INVOKED)
- #if defined(_MSC_VER) && (_MSC_VER >= 1915)
- #pragma warning (push)
- #pragma warning (disable : 4643)
- #endif
- namespace std {
- struct nothrow_t;
- }
- #if defined(_MSC_VER) && (_MSC_VER >= 1915)
- #pragma warning (pop)
- #endif
- namespace boost{
- namespace move_upmu {
- template<class T>
- struct unique_ptr_if
- {
- typedef ::boost::movelib::unique_ptr<T> t_is_not_array;
- };
- template<class T>
- struct unique_ptr_if<T[]>
- {
- typedef ::boost::movelib::unique_ptr<T[]> t_is_array_of_unknown_bound;
- };
- template<class T, std::size_t N>
- struct unique_ptr_if<T[N]>
- {
- typedef void t_is_array_of_known_bound;
- };
- template <int Dummy = 0>
- struct nothrow_holder
- {
- static std::nothrow_t *pnothrow;
- };
- template <int Dummy>
- std::nothrow_t *nothrow_holder<Dummy>::pnothrow =
- reinterpret_cast<std::nothrow_t *>(0x1234);
- }
- }
- #endif
- namespace boost{
- namespace movelib {
- #if defined(BOOST_MOVE_DOXYGEN_INVOKED) || !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
- template<class T, class... Args>
- inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
- typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array)
- make_unique(BOOST_FWD_REF(Args)... args)
- { return unique_ptr<T>(new T(::boost::forward<Args>(args)...)); }
- template<class T, class... Args>
- inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
- typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array)
- make_unique_nothrow(BOOST_FWD_REF(Args)... args)
- { return unique_ptr<T>(new (*boost::move_upmu::nothrow_holder<>::pnothrow)T(::boost::forward<Args>(args)...)); }
- #else
- #define BOOST_MOVE_MAKE_UNIQUE_CODE(N)\
- template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N>\
- typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array\
- make_unique( BOOST_MOVE_UREF##N)\
- { return unique_ptr<T>( new T( BOOST_MOVE_FWD##N ) ); }\
- \
- template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N>\
- typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array\
- make_unique_nothrow( BOOST_MOVE_UREF##N)\
- { return unique_ptr<T>( new (*boost::move_upmu::nothrow_holder<>::pnothrow)T ( BOOST_MOVE_FWD##N ) ); }\
-
- BOOST_MOVE_ITERATE_0TO9(BOOST_MOVE_MAKE_UNIQUE_CODE)
- #undef BOOST_MOVE_MAKE_UNIQUE_CODE
- #endif
- template<class T>
- inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
- typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array)
- make_unique_definit()
- {
- return unique_ptr<T>(new T);
- }
- template<class T>
- inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
- typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array)
- make_unique_nothrow_definit()
- {
- return unique_ptr<T>(new (*boost::move_upmu::nothrow_holder<>::pnothrow)T);
- }
- template<class T>
- inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
- typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_unknown_bound)
- make_unique(std::size_t n)
- {
- typedef typename ::boost::move_upmu::remove_extent<T>::type U;
- return unique_ptr<T>(new U[n]());
- }
- template<class T>
- inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
- typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_unknown_bound)
- make_unique_nothrow(std::size_t n)
- {
- typedef typename ::boost::move_upmu::remove_extent<T>::type U;
- return unique_ptr<T>(new (*boost::move_upmu::nothrow_holder<>::pnothrow)U[n]());
- }
- template<class T>
- inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
- typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_unknown_bound)
- make_unique_definit(std::size_t n)
- {
- typedef typename ::boost::move_upmu::remove_extent<T>::type U;
- return unique_ptr<T>(new U[n]);
- }
- template<class T>
- inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
- typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_unknown_bound)
- make_unique_nothrow_definit(std::size_t n)
- {
- typedef typename ::boost::move_upmu::remove_extent<T>::type U;
- return unique_ptr<T>(new (*boost::move_upmu::nothrow_holder<>::pnothrow) U[n]);
- }
- #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
- template<class T, class... Args>
- inline BOOST_MOVE_DOC1ST(unspecified,
- typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_known_bound)
- make_unique(BOOST_FWD_REF(Args) ...) = delete;
- template<class T, class... Args>
- inline BOOST_MOVE_DOC1ST(unspecified,
- typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_known_bound)
- make_unique_definit(BOOST_FWD_REF(Args) ...) = delete;
- template<class T, class... Args>
- inline BOOST_MOVE_DOC1ST(unspecified,
- typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_known_bound)
- make_unique_nothrow(BOOST_FWD_REF(Args) ...) = delete;
- template<class T, class... Args>
- inline BOOST_MOVE_DOC1ST(unspecified,
- typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_known_bound)
- make_unique_nothrow_definit(BOOST_FWD_REF(Args) ...) = delete;
- #endif
- }
- }
- #include <boost/move/detail/config_end.hpp>
- #endif
|