Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-15 08:51:11

0001 //////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga 2006-2014. Distributed under the Boost
0004 // Software License, Version 1.0. (See accompanying file
0005 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // See http://www.boost.org/libs/move for documentation.
0008 //
0009 //////////////////////////////////////////////////////////////////////////////
0010 
0011 #ifndef BOOST_MOVE_MAKE_UNIQUE_HPP_INCLUDED
0012 #define BOOST_MOVE_MAKE_UNIQUE_HPP_INCLUDED
0013 
0014 #ifndef BOOST_CONFIG_HPP
0015 #  include <boost/config.hpp>
0016 #endif
0017 0018 ">#
0019 #if defined(BOOST_HAS_PRAGMA_ONCE)
0020 #  pragma once
0021 #endif
0022 
0023 #include <boost/move/detail/config_begin.hpp>
0024 #include <boost/move/detail/workaround.hpp>
0025 #include <boost/move/utility_core.hpp>
0026 #include <boost/move/unique_ptr.hpp>
0027 #include <cstddef>   //for std::size_t
0028 #include <boost/move/detail/unique_ptr_meta_utils.hpp>
0029 #ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES
0030 #  include <boost/move/detail/fwd_macros.hpp>
0031 #endif
0032 
0033 //!\file
0034 //! Defines "make_unique" functions, which are factories to create instances
0035 //! of unique_ptr depending on the passed arguments.
0036 //!
0037 //! This header can be a bit heavyweight in C++03 compilers due to the use of the
0038 //! preprocessor library, that's why it's a a separate header from <tt>unique_ptr.hpp</tt>
0039  
0040 #if !defined(BOOST_MOVE_DOXYGEN_INVOKED)
0041 
0042 #if defined(_MSC_VER) && (_MSC_VER >= 1915)
0043    #pragma warning (push)
0044    #pragma warning (disable : 4643) // Forward declaring 'X' in namespace std is not permitted by the C++ Standard
0045 #endif
0046 
0047 namespace std {   //no namespace versioning in clang+libc++
0048 
0049 struct nothrow_t;
0050 
0051 }  //namespace std {
0052 
0053 #if defined(_MSC_VER) && (_MSC_VER >= 1915)
0054    #pragma warning (pop)
0055 #endif
0056 
0057 
0058 namespace boost{
0059 namespace move_upmu {
0060 
0061 //Compile time switch between
0062 //single element, unknown bound array
0063 //and known bound array
0064 template<class T>
0065 struct unique_ptr_if
0066 {
0067    typedef ::boost::movelib::unique_ptr<T> t_is_not_array;
0068 };
0069 
0070 template<class T>
0071 struct unique_ptr_if<T[]>
0072 {
0073    typedef ::boost::movelib::unique_ptr<T[]> t_is_array_of_unknown_bound;
0074 };
0075 
0076 template<class T, std::size_t N>
0077 struct unique_ptr_if<T[N]>
0078 {
0079    typedef void t_is_array_of_known_bound;
0080 };
0081 
0082 template <int Dummy = 0>
0083 struct nothrow_holder
0084 {
0085    static std::nothrow_t *pnothrow;   
0086 };
0087 
0088 template <int Dummy>
0089 std::nothrow_t *nothrow_holder<Dummy>::pnothrow = 
0090    reinterpret_cast<std::nothrow_t *>(0x1234);  //Avoid reference to null errors in sanitizers
0091 
0092 }  //namespace move_upmu {
0093 }  //namespace boost{
0094 
0095 #endif   //!defined(BOOST_MOVE_DOXYGEN_INVOKED)
0096 
0097 namespace boost{
0098 namespace movelib {
0099 
0100 #if defined(BOOST_MOVE_DOXYGEN_INVOKED) || !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
0101 
0102 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is not an array.
0103 //!
0104 //! <b>Returns</b>: <tt>unique_ptr<T>(new T(std::forward<Args>(args)...))</tt>.
0105 template<class T, class... Args>
0106 inline BOOST_MOVE_DOC1ST(unique_ptr<T>, 
0107    typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array)
0108       make_unique(BOOST_FWD_REF(Args)... args)
0109 {  return unique_ptr<T>(new T(::boost::forward<Args>(args)...));  }
0110 
0111 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is not an array.
0112 //!
0113 //! <b>Returns</b>: <tt>unique_ptr<T>(new T(std::nothrow)(std::forward<Args>(args)...))</tt>.
0114 template<class T, class... Args>
0115 inline BOOST_MOVE_DOC1ST(unique_ptr<T>, 
0116    typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array)
0117       make_unique_nothrow(BOOST_FWD_REF(Args)... args)
0118 {  return unique_ptr<T>(new (*boost::move_upmu::nothrow_holder<>::pnothrow)T(::boost::forward<Args>(args)...));  }
0119 
0120 #else
0121    #define BOOST_MOVE_MAKE_UNIQUE_CODE(N)\
0122       template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N>\
0123       typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array\
0124          make_unique( BOOST_MOVE_UREF##N)\
0125       {  return unique_ptr<T>( new T( BOOST_MOVE_FWD##N ) );  }\
0126       \
0127       template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N>\
0128       typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array\
0129          make_unique_nothrow( BOOST_MOVE_UREF##N)\
0130       {  return unique_ptr<T>( new (*boost::move_upmu::nothrow_holder<>::pnothrow)T ( BOOST_MOVE_FWD##N ) );  }\
0131       //
0132    BOOST_MOVE_ITERATE_0TO9(BOOST_MOVE_MAKE_UNIQUE_CODE)
0133    #undef BOOST_MOVE_MAKE_UNIQUE_CODE
0134 
0135 #endif
0136 
0137 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is not an array.
0138 //!
0139 //! <b>Returns</b>: <tt>unique_ptr<T>(new T)</tt> (default initialization)
0140 template<class T>
0141 inline BOOST_MOVE_DOC1ST(unique_ptr<T>, 
0142    typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array)
0143       make_unique_definit()
0144 {
0145     return unique_ptr<T>(new T);
0146 }
0147 
0148 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is not an array.
0149 //!
0150 //! <b>Returns</b>: <tt>unique_ptr<T>(new T(std::nothrow)</tt> (default initialization)
0151 template<class T>
0152 inline BOOST_MOVE_DOC1ST(unique_ptr<T>, 
0153    typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array)
0154       make_unique_nothrow_definit()
0155 {
0156     return unique_ptr<T>(new (*boost::move_upmu::nothrow_holder<>::pnothrow)T);
0157 }
0158 
0159 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is an array of 
0160 //!   unknown bound.
0161 //!
0162 //! <b>Returns</b>: <tt>unique_ptr<T>(new remove_extent_t<T>[n]())</tt> (value initialization)
0163 template<class T>
0164 inline BOOST_MOVE_DOC1ST(unique_ptr<T>, 
0165    typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_unknown_bound)
0166       make_unique(std::size_t n)
0167 {
0168     typedef typename ::boost::move_upmu::remove_extent<T>::type U;
0169     return unique_ptr<T>(new U[n]());
0170 }
0171 
0172 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is an array of 
0173 //!   unknown bound.
0174 //!
0175 //! <b>Returns</b>: <tt>unique_ptr<T>(new (std::nothrow)remove_extent_t<T>[n]())</tt> (value initialization)
0176 template<class T>
0177 inline BOOST_MOVE_DOC1ST(unique_ptr<T>, 
0178    typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_unknown_bound)
0179       make_unique_nothrow(std::size_t n)
0180 {
0181     typedef typename ::boost::move_upmu::remove_extent<T>::type U;
0182     return unique_ptr<T>(new (*boost::move_upmu::nothrow_holder<>::pnothrow)U[n]());
0183 }
0184 
0185 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is an array of 
0186 //!   unknown bound.
0187 //!
0188 //! <b>Returns</b>: <tt>unique_ptr<T>(new remove_extent_t<T>[n])</tt> (default initialization)
0189 template<class T>
0190 inline BOOST_MOVE_DOC1ST(unique_ptr<T>, 
0191    typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_unknown_bound)
0192       make_unique_definit(std::size_t n)
0193 {
0194     typedef typename ::boost::move_upmu::remove_extent<T>::type U;
0195     return unique_ptr<T>(new U[n]);
0196 }
0197 
0198 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is an array of 
0199 //!   unknown bound.
0200 //!
0201 //! <b>Returns</b>: <tt>unique_ptr<T>(new (std::nothrow)remove_extent_t<T>[n])</tt> (default initialization)
0202 template<class T>
0203 inline BOOST_MOVE_DOC1ST(unique_ptr<T>, 
0204    typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_unknown_bound)
0205       make_unique_nothrow_definit(std::size_t n)
0206 {
0207     typedef typename ::boost::move_upmu::remove_extent<T>::type U;
0208     return unique_ptr<T>(new (*boost::move_upmu::nothrow_holder<>::pnothrow) U[n]);
0209 }
0210 
0211 #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
0212 
0213 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is
0214 //!   an array of known bound.
0215 template<class T, class... Args>
0216 inline BOOST_MOVE_DOC1ST(unspecified, 
0217    typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_known_bound)
0218       make_unique(BOOST_FWD_REF(Args) ...) = delete;
0219 
0220 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is
0221 //!   an array of known bound.
0222 template<class T, class... Args>
0223 inline BOOST_MOVE_DOC1ST(unspecified, 
0224    typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_known_bound)
0225       make_unique_definit(BOOST_FWD_REF(Args) ...) = delete;
0226 
0227 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is
0228 //!   an array of known bound.
0229 template<class T, class... Args>
0230 inline BOOST_MOVE_DOC1ST(unspecified, 
0231    typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_known_bound)
0232       make_unique_nothrow(BOOST_FWD_REF(Args) ...) = delete;
0233 
0234 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is
0235 //!   an array of known bound.
0236 template<class T, class... Args>
0237 inline BOOST_MOVE_DOC1ST(unspecified, 
0238    typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_known_bound)
0239       make_unique_nothrow_definit(BOOST_FWD_REF(Args) ...) = delete;
0240 
0241 #endif
0242 
0243 }  //namespace movelib {
0244 
0245 }  //namespace boost{
0246 
0247 #include <boost/move/detail/config_end.hpp>
0248 
0249 #endif   //#ifndef BOOST_MOVE_MAKE_UNIQUE_HPP_INCLUDED