Skip to content

Commit

Permalink
Remove uses of boost::is_array
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Oct 6, 2024
1 parent 173cf9a commit 0bedddb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
15 changes: 7 additions & 8 deletions include/boost/smart_ptr/allocate_unique.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/core/first_scalar.hpp>
#include <boost/core/noinit_adaptor.hpp>
#include <boost/core/pointer_traits.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/is_bounded_array.hpp>
#include <boost/type_traits/is_unbounded_array.hpp>
#include <boost/type_traits/type_identity.hpp>
Expand Down Expand Up @@ -256,15 +255,15 @@ operator!=(std::nullptr_t,
template<class A>
inline void
sp_alloc_clear(A& a, typename boost::allocator_pointer<A>::type p, std::size_t,
boost::false_type)
std::false_type)
{
boost::alloc_destroy(a, boost::to_address(p));
}

template<class A>
inline void
sp_alloc_clear(A& a, typename boost::allocator_pointer<A>::type p,
std::size_t n, boost::true_type)
std::size_t n, std::true_type)
{
#if defined(BOOST_MSVC) && BOOST_MSVC < 1800
if (!p) {
Expand Down Expand Up @@ -293,7 +292,7 @@ class alloc_deleter
: base(empty_init_t(), a) { }

void operator()(pointer p) {
detail::sp_alloc_clear(base::get(), p.ptr(), p.size(), is_array<T>());
detail::sp_alloc_clear(base::get(), p.ptr(), p.size(), std::is_array<T>());
base::get().deallocate(p.ptr(), p.size());
}
};
Expand Down Expand Up @@ -351,7 +350,7 @@ class sp_alloc_make {
} /* detail */

template<class T, class A>
inline typename std::enable_if<!is_array<T>::value,
inline typename std::enable_if<!std::is_array<T>::value,
std::unique_ptr<T, alloc_deleter<T, A> > >::type
allocate_unique(const A& alloc)
{
Expand All @@ -361,7 +360,7 @@ allocate_unique(const A& alloc)
}

template<class T, class A, class... Args>
inline typename std::enable_if<!is_array<T>::value,
inline typename std::enable_if<!std::is_array<T>::value,
std::unique_ptr<T, alloc_deleter<T, A> > >::type
allocate_unique(const A& alloc, Args&&... args)
{
Expand All @@ -371,7 +370,7 @@ allocate_unique(const A& alloc, Args&&... args)
}

template<class T, class A>
inline typename std::enable_if<!is_array<T>::value,
inline typename std::enable_if<!std::is_array<T>::value,
std::unique_ptr<T, alloc_deleter<T, A> > >::type
allocate_unique(const A& alloc, typename type_identity<T>::type&& value)
{
Expand All @@ -381,7 +380,7 @@ allocate_unique(const A& alloc, typename type_identity<T>::type&& value)
}

template<class T, class A>
inline typename std::enable_if<!is_array<T>::value,
inline typename std::enable_if<!std::is_array<T>::value,
std::unique_ptr<T, alloc_deleter<T, noinit_adaptor<A> > > >::type
allocate_unique_noinit(const A& alloc)
{
Expand Down
9 changes: 4 additions & 5 deletions include/boost/smart_ptr/make_unique.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Distributed under the Boost Software License, Version 1.0.
#ifndef BOOST_SMART_PTR_MAKE_UNIQUE_HPP
#define BOOST_SMART_PTR_MAKE_UNIQUE_HPP

#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/is_unbounded_array.hpp>
#include <memory>
#include <utility>
Expand All @@ -17,28 +16,28 @@ Distributed under the Boost Software License, Version 1.0.
namespace boost {

template<class T>
inline typename std::enable_if<!is_array<T>::value, std::unique_ptr<T> >::type
inline typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T> >::type
make_unique()
{
return std::unique_ptr<T>(new T());
}

template<class T, class... Args>
inline typename std::enable_if<!is_array<T>::value, std::unique_ptr<T> >::type
inline typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T> >::type
make_unique(Args&&... args)
{
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}

template<class T>
inline typename std::enable_if<!is_array<T>::value, std::unique_ptr<T> >::type
inline typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T> >::type
make_unique(typename std::remove_reference<T>::type&& value)
{
return std::unique_ptr<T>(new T(std::move(value)));
}

template<class T>
inline typename std::enable_if<!is_array<T>::value, std::unique_ptr<T> >::type
inline typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T> >::type
make_unique_noinit()
{
return std::unique_ptr<T>(new T);
Expand Down

0 comments on commit 0bedddb

Please sign in to comment.