heap: use c++14 wherever possible

* remove c++11 workarounds
* use std type traits
* use std::array
* use nullptr
* use noexcept
This commit is contained in:
Tim Blechmann
2024-11-09 11:48:11 +08:00
parent 8c1f024153
commit 8ae6cfd336
24 changed files with 242 additions and 344 deletions
+24 -32
View File
@@ -131,17 +131,17 @@ jobs:
# supported: true
# macos
- description: macos-11
toolset: clang
cxxstd: "14,17,2a"
os: macos-11
supported: true
- description: macos-12
- description: macos-13
toolset: clang
cxxstd: "14,17,20"
os: macos-11
supported: true
- description: macos-13
- description: macos-14
toolset: clang
cxxstd: "14,17,20"
os: macos-11
supported: true
- description: macos-15
toolset: clang
cxxstd: "14,17,20"
os: macos-11
@@ -253,40 +253,32 @@ jobs:
fail-fast: false
matrix:
include:
- description: msvc-14.2-32
toolset: msvc-14.2
cxxstd: "14,17"
cxxflags: "cxxflags=-D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING=1"
supported: true
addrmd: 32
- toolset: msvc-14.0
cxxstd: "14,latest"
addrmd: 32,64
os: windows-2019
- description: msvc-14.3-32
toolset: msvc-14.3
cxxstd: "14,17,20"
cxxflags: "cxxflags=-D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING=1"
supported: true
addrmd: 32
- toolset: msvc-14.2
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2019
- description: msvc-14.2-64
toolset: msvc-14.2
cxxstd: "14,17"
cxxflags: "cxxflags=-D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING=1"
supported: true
addrmd: 64
os: windows-2019
- description: msvc-14.3-64
toolset: msvc-14.3
cxxstd: "14,17,20"
cxxflags: "cxxflags=-D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING=1"
- toolset: msvc-14.3
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2022
supported: true
- toolset: clang-win
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2022
supported: true
addrmd: 64
os: windows-2019
- toolset: gcc
cxxstd: "14,17,2a"
addrmd: 64
cxxflags: "cxxflags=-Wa,-mbig-obj"
supported: true
os: windows-2019
supported: true
needs: [runner-selection]
# runs-on: ${{ fromJSON(needs.runner-selection.outputs.labelmatrix)[matrix.os] }}
+5 -3
View File
@@ -10,17 +10,20 @@ project(boost_heap VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
option(BOOST_HEAP_BUILD_TESTS "Build boost::heap tests" OFF)
option(BOOST_HEAP_USE_FILE_SET "Use FILE_SET for boost::heap" OFF)
if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
add_library(boost_heap INTERFACE)
add_library(Boost::heap ALIAS boost_heap)
target_include_directories(boost_heap INTERFACE include)
target_compile_features(boost_heap INTERFACE cxx_std_14)
set_target_properties( boost_heap PROPERTIES CMAKE_CXX_STANDARD_REQUIRED 14)
target_link_libraries(boost_heap
INTERFACE
Boost::array
Boost::assert
Boost::bind
Boost::concept_check
Boost::config
Boost::core
@@ -29,7 +32,6 @@ target_link_libraries(boost_heap
Boost::parameter
Boost::static_assert
Boost::throw_exception
Boost::type_traits
)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.23 AND BOOST_HEAP_USE_FILE_SET)
+1 -4
View File
@@ -6,9 +6,7 @@
require-b2 5.2 ;
constant boost_dependencies :
/boost/array//boost_array
/boost/assert//boost_assert
/boost/bind//boost_bind
/boost/concept_check//boost_concept_check
/boost/config//boost_config
/boost/core//boost_core
@@ -16,8 +14,7 @@ constant boost_dependencies :
/boost/iterator//boost_iterator
/boost/parameter//boost_parameter
/boost/static_assert//boost_static_assert
/boost/throw_exception//boost_throw_exception
/boost/type_traits//boost_type_traits ;
/boost/throw_exception//boost_throw_exception ;
project /boost/heap
: common-requirements
+17 -22
View File
@@ -10,6 +10,7 @@
#define BOOST_HEAP_BINOMIAL_HEAP_HPP
#include <algorithm>
#include <type_traits>
#include <utility>
#include <boost/assert.hpp>
@@ -46,7 +47,7 @@ template < typename T, typename Parspec >
struct make_binomial_heap_base
{
static const bool constant_time_size
= parameter::binding< Parspec, tag::constant_time_size, boost::true_type >::type::value;
= parameter::binding< Parspec, tag::constant_time_size, std::true_type >::type::value;
typedef typename detail::make_heap_base< T, Parspec, constant_time_size >::type base_type;
typedef typename detail::make_heap_base< T, Parspec, constant_time_size >::allocator_argument allocator_argument;
typedef typename detail::make_heap_base< T, Parspec, constant_time_size >::compare_argument compare_argument;
@@ -65,7 +66,6 @@ struct make_binomial_heap_base
allocator_type( alloc )
{}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
type( type const& rhs ) :
base_type( rhs ),
allocator_type( rhs )
@@ -89,7 +89,6 @@ struct make_binomial_heap_base
allocator_type::operator=( static_cast< allocator_type const& >( rhs ) );
return *this;
}
#endif
};
};
@@ -248,20 +247,19 @@ public:
static_cast< super_t& >( *this ) = rhs;
if ( rhs.empty() )
top_element = NULL;
top_element = nullptr;
else
clone_forest( rhs );
return *this;
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
/// \copydoc boost::heap::priority_queue::priority_queue(priority_queue &&)
binomial_heap( binomial_heap&& rhs ) :
super_t( std::move( rhs ) ),
top_element( rhs.top_element )
{
trees.splice( trees.begin(), rhs.trees );
rhs.top_element = NULL;
rhs.top_element = nullptr;
}
/// \copydoc boost::heap::priority_queue::operator=(priority_queue &&)
@@ -271,10 +269,9 @@ public:
super_t::operator=( std::move( rhs ) );
trees.splice( trees.begin(), rhs.trees );
top_element = rhs.top_element;
rhs.top_element = NULL;
rhs.top_element = nullptr;
return *this;
}
#endif
~binomial_heap( void )
{
@@ -284,7 +281,7 @@ public:
/// \copydoc boost::heap::priority_queue::empty
bool empty( void ) const
{
return top_element == NULL;
return top_element == nullptr;
}
/**
@@ -318,7 +315,7 @@ public:
trees.clear_and_dispose( disposer( *this ) );
size_holder::set_size( 0 );
top_element = NULL;
top_element = nullptr;
}
/// \copydoc boost::heap::priority_queue::get_allocator
@@ -364,7 +361,6 @@ public:
return handle_type( n );
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
/**
* \b Effects: Adds a new element to the priority queue. The element is directly constructed in-place. Returns
* handle to element.
@@ -387,7 +383,6 @@ public:
sanity_check();
return handle_type( n );
}
#endif
/**
* \b Effects: Removes the top element from the priority queue.
@@ -421,7 +416,7 @@ public:
}
if ( trees.empty() )
top_element = NULL;
top_element = nullptr;
else
update_top_element();
@@ -546,7 +541,7 @@ public:
size_holder::set_size( new_size );
rhs.set_size( 0 );
rhs.top_element = NULL;
rhs.top_element = nullptr;
super_t::set_stability_count( ( std::max )( super_t::get_stability_count(), rhs.get_stability_count() ) );
rhs.set_stability_count( 0 );
@@ -574,7 +569,7 @@ public:
/// \copydoc boost::heap::fibonacci_heap::ordered_end
ordered_iterator ordered_end( void ) const
{
return ordered_iterator( NULL, super_t::value_comp() );
return ordered_iterator( nullptr, super_t::value_comp() );
}
/**
@@ -653,7 +648,7 @@ private:
BOOST_HEAP_ASSERT( !rhs.empty() );
node_list_iterator this_iterator = trees.begin();
node_pointer carry_node = NULL;
node_pointer carry_node = nullptr;
while ( !rhs.trees.empty() ) {
node_pointer rhs_node = static_cast< node_pointer >( &rhs.trees.front() );
@@ -672,7 +667,7 @@ try_again:
if ( carry_node ) {
if ( carry_node->child_count() < this_degree ) {
trees.insert( this_iterator, *carry_node );
carry_node = NULL;
carry_node = nullptr;
} else {
rhs.trees.pop_front();
carry_node = merge_trees( carry_node, rhs_node );
@@ -694,7 +689,7 @@ try_again:
if ( carry_node ) {
if ( carry_node->child_count() < this_degree ) {
trees.insert( this_iterator, *carry_node );
carry_node = NULL;
carry_node = nullptr;
++this_iterator;
} else if ( carry_node->child_count() == rhs_degree ) {
rhs.trees.pop_front();
@@ -724,7 +719,7 @@ try_again:
if ( carry_node->child_count() < rhs_degree ) {
trees.insert( this_iterator, *carry_node );
trees.insert( this_iterator, *rhs_node );
carry_node = NULL;
carry_node = nullptr;
} else
carry_node = merge_trees( rhs_node, carry_node );
} else
@@ -759,7 +754,7 @@ try_again:
{
BOOST_HEAP_ASSERT( trees.empty() );
typedef typename node_type::template node_cloner< allocator_type > node_cloner;
trees.clone_from( rhs.trees, node_cloner( *this, NULL ), detail::nop_disposer() );
trees.clone_from( rhs.trees, node_cloner( *this, nullptr ), detail::nop_disposer() );
update_top_element();
}
@@ -860,11 +855,11 @@ try_again:
if ( size )
top_element = static_cast< node_pointer >( &*child_list.begin() ); // not correct, but we will reset it later
else
top_element = NULL;
top_element = nullptr;
for ( node_list_iterator it = child_list.begin(); it != child_list.end(); ++it ) {
node_pointer n = static_cast< node_pointer >( &*it );
n->parent = NULL;
n->parent = nullptr;
}
trees.splice( trees.end(), child_list, child_list.begin(), child_list.end() );
+6 -13
View File
@@ -155,7 +155,6 @@ public:
q_( rhs.q_ )
{}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
d_ary_heap( d_ary_heap&& rhs ) :
super_t( std::move( rhs ) ),
q_( std::move( rhs.q_ ) )
@@ -167,7 +166,6 @@ public:
q_ = std::move( rhs.q_ );
return *this;
}
#endif
d_ary_heap& operator=( d_ary_heap const& rhs )
{
@@ -214,7 +212,6 @@ public:
siftup( q_.size() - 1 );
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
template < class... Args >
void emplace( Args&&... args )
{
@@ -222,7 +219,7 @@ public:
reset_index( size() - 1, size() - 1 );
siftup( q_.size() - 1 );
}
#endif
void pop( void )
{
BOOST_ASSERT( !empty() );
@@ -414,9 +411,9 @@ struct select_dary_heap
{
static const bool is_mutable = extract_mutable< BoundArgs >::value;
typedef typename boost::conditional< is_mutable,
priority_queue_mutable_wrapper< d_ary_heap< T, BoundArgs, nop_index_updater > >,
d_ary_heap< T, BoundArgs, nop_index_updater > >::type type;
typedef typename std::conditional< is_mutable,
priority_queue_mutable_wrapper< d_ary_heap< T, BoundArgs, nop_index_updater > >,
d_ary_heap< T, BoundArgs, nop_index_updater > >::type type;
};
} /* namespace detail */
@@ -516,7 +513,6 @@ public:
super_t( rhs )
{}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
/// \copydoc boost::heap::priority_queue::priority_queue(priority_queue &&)
d_ary_heap( d_ary_heap&& rhs ) :
super_t( std::move( rhs ) )
@@ -528,7 +524,6 @@ public:
super_t::operator=( std::move( rhs ) );
return *this;
}
#endif
/// \copydoc boost::heap::priority_queue::operator=(priority_queue const &)
d_ary_heap& operator=( d_ary_heap const& rhs )
@@ -574,19 +569,17 @@ public:
}
/// \copydoc boost::heap::priority_queue::push
typename boost::conditional< is_mutable, handle_type, void >::type push( value_type const& v )
typename std::conditional< is_mutable, handle_type, void >::type push( value_type const& v )
{
return super_t::push( v );
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
/// \copydoc boost::heap::priority_queue::emplace
template < class... Args >
typename boost::conditional< is_mutable, handle_type, void >::type emplace( Args&&... args )
typename std::conditional< is_mutable, handle_type, void >::type emplace( Args&&... args )
{
return super_t::emplace( std::forward< Args >( args )... );
}
#endif
/// \copydoc boost::heap::priority_queue::operator<(HeapType const & rhs) const
template < typename HeapType >
@@ -55,7 +55,7 @@ struct heap_equivalence_copy
BOOST_CONCEPT_ASSERT( (boost::heap::PriorityQueue< Heap2 >));
// if this assertion is triggered, the value_compare types are incompatible
BOOST_STATIC_ASSERT( ( boost::is_same< typename Heap1::value_compare, typename Heap2::value_compare >::value ) );
BOOST_STATIC_ASSERT( ( std::is_same< typename Heap1::value_compare, typename Heap2::value_compare >::value ) );
if ( Heap1::constant_time_size && Heap2::constant_time_size )
if ( lhs.size() != rhs.size() )
@@ -96,7 +96,7 @@ struct heap_equivalence_iteration
BOOST_CONCEPT_ASSERT( (boost::heap::PriorityQueue< Heap2 >));
// if this assertion is triggered, the value_compare types are incompatible
BOOST_STATIC_ASSERT( ( boost::is_same< typename Heap1::value_compare, typename Heap2::value_compare >::value ) );
BOOST_STATIC_ASSERT( ( std::is_same< typename Heap1::value_compare, typename Heap2::value_compare >::value ) );
if ( Heap1::constant_time_size && Heap2::constant_time_size )
if ( lhs.size() != rhs.size() )
@@ -131,7 +131,7 @@ bool heap_equality( Heap1 const& lhs, Heap2 const& rhs )
{
const bool use_ordered_iterators = Heap1::has_ordered_iterators && Heap2::has_ordered_iterators;
typedef typename boost::conditional< use_ordered_iterators, heap_equivalence_iteration, heap_equivalence_copy >::type
typedef typename std::conditional< use_ordered_iterators, heap_equivalence_iteration, heap_equivalence_copy >::type
equivalence_check;
equivalence_check eq_check;
@@ -213,7 +213,7 @@ bool heap_compare( Heap1 const& lhs, Heap2 const& rhs )
const bool use_ordered_iterators = Heap1::has_ordered_iterators && Heap2::has_ordered_iterators;
typedef
typename boost::conditional< use_ordered_iterators, heap_compare_iteration, heap_compare_copy >::type compare_check;
typename std::conditional< use_ordered_iterators, heap_compare_iteration, heap_compare_copy >::type compare_check;
compare_check check_object;
return check_object( lhs, rhs );
+5 -11
View File
@@ -29,7 +29,7 @@ namespace bi = boost::intrusive;
template < bool auto_unlink = false >
struct heap_node_base :
bi::list_base_hook<
typename boost::conditional< auto_unlink, bi::link_mode< bi::auto_unlink >, bi::link_mode< bi::safe_link > >::type >
typename std::conditional< auto_unlink, bi::link_mode< bi::auto_unlink >, bi::link_mode< bi::safe_link > >::type >
{};
typedef bi::list< heap_node_base< false > > heap_node_list;
@@ -165,12 +165,10 @@ public:
value( v )
{}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
template < class... Args >
heap_node( Args&&... args ) :
value( std::forward< Args >( args )... )
{}
#endif
/* protected: */
heap_node( heap_node const& rhs ) :
@@ -220,16 +218,14 @@ struct parent_pointing_heap_node : heap_node< value_type >
parent_pointing_heap_node( value_type const& v ) :
super_t( v ),
parent( NULL )
parent( nullptr )
{}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
template < class... Args >
parent_pointing_heap_node( Args&&... args ) :
super_t( std::forward< Args >( args )... ),
parent( NULL )
parent( nullptr )
{}
#endif
template < typename Alloc >
struct node_cloner
@@ -275,12 +271,12 @@ struct parent_pointing_heap_node : heap_node< value_type >
{
BOOST_HEAP_ASSERT( parent );
parent->children.erase( heap_node_list::s_iterator_to( *this ) );
parent = NULL;
parent = nullptr;
}
void add_child( parent_pointing_heap_node* n )
{
BOOST_HEAP_ASSERT( n->parent == NULL );
BOOST_HEAP_ASSERT( n->parent == nullptr );
n->parent = this;
super_t::add_child( n );
}
@@ -309,13 +305,11 @@ struct marked_heap_node : parent_pointing_heap_node< value_type >
mark( false )
{}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
template < class... Args >
marked_heap_node( Args&&... args ) :
super_t( std::forward< Args >( args )... ),
mark( false )
{}
#endif
marked_heap_node* get_parent( void )
{
-1
View File
@@ -9,7 +9,6 @@
#ifndef BOOST_HEAP_DETAIL_ILOG2_HPP
#define BOOST_HEAP_DETAIL_ILOG2_HPP
#include <string> // std::size_t
namespace boost { namespace heap {
namespace detail {
+1 -6
View File
@@ -159,7 +159,6 @@ protected:
return *this;
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
priority_queue_mutable_wrapper( priority_queue_mutable_wrapper&& rhs ) :
q_( std::move( rhs.q_ ) )
{
@@ -174,8 +173,6 @@ protected:
std::swap( objects, rhs.objects );
return *this;
}
#endif
public:
template < typename iterator_type >
@@ -235,7 +232,7 @@ public:
ordered_iterator( void ) :
adaptor_type( 0 ),
unvisited_nodes( indirect_cmp() ),
q_( NULL )
q_( nullptr )
{}
ordered_iterator( const priority_queue_mutable_wrapper* q, indirect_cmp const& cmp ) :
@@ -354,7 +351,6 @@ public:
return handle_type( ret );
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
template < class... Args >
handle_type emplace( Args&&... args )
{
@@ -363,7 +359,6 @@ public:
q_.push( ret );
return handle_type( ret );
}
#endif
void pop( void )
{
@@ -65,9 +65,9 @@ class ordered_adaptor_iterator :
public:
ordered_adaptor_iterator( void ) :
container( NULL ),
container( nullptr ),
current_index( ( std::numeric_limits< size_t >::max )() ),
unvisited_nodes( compare_by_heap_value( NULL, ValueCompare() ) )
unvisited_nodes( compare_by_heap_value( nullptr, ValueCompare() ) )
{}
ordered_adaptor_iterator( const ContainerType* container, ValueCompare const& cmp ) :
+60 -75
View File
@@ -11,6 +11,7 @@
#include <limits>
#include <stdexcept>
#include <type_traits>
#include <utility>
#include <boost/core/allocator_access.hpp>
@@ -21,9 +22,6 @@
#include <boost/heap/heap_merge.hpp>
#include <boost/heap/policies.hpp>
#include <boost/type_traits/is_nothrow_move_assignable.hpp>
#include <boost/type_traits/is_nothrow_move_constructible.hpp>
namespace boost { namespace heap { namespace detail {
template < bool ConstantSize, class SizeType >
@@ -32,63 +30,64 @@ struct size_holder
static const bool constant_time_size = ConstantSize;
typedef SizeType size_type;
size_holder( void ) BOOST_NOEXCEPT : size_( 0 )
size_holder( void ) noexcept :
size_( 0 )
{}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
size_holder( size_holder&& rhs ) BOOST_NOEXCEPT : size_( rhs.size_ )
size_holder( size_holder&& rhs ) noexcept :
size_( rhs.size_ )
{
rhs.size_ = 0;
}
size_holder( size_holder const& rhs ) BOOST_NOEXCEPT : size_( rhs.size_ )
size_holder( size_holder const& rhs ) noexcept :
size_( rhs.size_ )
{}
size_holder& operator=( size_holder&& rhs ) BOOST_NOEXCEPT
size_holder& operator=( size_holder&& rhs ) noexcept
{
size_ = rhs.size_;
rhs.size_ = 0;
return *this;
}
size_holder& operator=( size_holder const& rhs ) BOOST_NOEXCEPT
size_holder& operator=( size_holder const& rhs ) noexcept
{
size_ = rhs.size_;
return *this;
}
#endif
SizeType get_size() const BOOST_NOEXCEPT
SizeType get_size() const noexcept
{
return size_;
}
void set_size( SizeType size ) BOOST_NOEXCEPT
void set_size( SizeType size ) noexcept
{
size_ = size;
}
void decrement() BOOST_NOEXCEPT
void decrement() noexcept
{
--size_;
}
void increment() BOOST_NOEXCEPT
void increment() noexcept
{
++size_;
}
void add( SizeType value ) BOOST_NOEXCEPT
void add( SizeType value ) noexcept
{
size_ += value;
}
void sub( SizeType value ) BOOST_NOEXCEPT
void sub( SizeType value ) noexcept
{
size_ -= value;
}
void swap( size_holder& rhs ) BOOST_NOEXCEPT
void swap( size_holder& rhs ) noexcept
{
std::swap( size_, rhs.size_ );
}
@@ -102,48 +101,46 @@ struct size_holder< false, SizeType >
static const bool constant_time_size = false;
typedef SizeType size_type;
size_holder( void ) BOOST_NOEXCEPT
size_holder( void ) noexcept
{}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
size_holder( size_holder&& ) BOOST_NOEXCEPT
size_holder( size_holder&& ) noexcept
{}
size_holder( size_holder const& ) BOOST_NOEXCEPT
size_holder( size_holder const& ) noexcept
{}
size_holder& operator=( size_holder&& ) BOOST_NOEXCEPT
size_holder& operator=( size_holder&& ) noexcept
{
return *this;
}
size_holder& operator=( size_holder const& ) BOOST_NOEXCEPT
size_holder& operator=( size_holder const& ) noexcept
{
return *this;
}
#endif
size_type get_size() const BOOST_NOEXCEPT
size_type get_size() const noexcept
{
return 0;
}
void set_size( size_type ) BOOST_NOEXCEPT
void set_size( size_type ) noexcept
{}
void decrement() BOOST_NOEXCEPT
void decrement() noexcept
{}
void increment() BOOST_NOEXCEPT
void increment() noexcept
{}
void add( SizeType /*value*/ ) BOOST_NOEXCEPT
void add( SizeType /*value*/ ) noexcept
{}
void sub( SizeType /*value*/ ) BOOST_NOEXCEPT
void sub( SizeType /*value*/ ) noexcept
{}
void swap( size_holder& /*rhs*/ ) BOOST_NOEXCEPT
void swap( size_holder& /*rhs*/ ) noexcept
{}
};
@@ -176,30 +173,29 @@ struct heap_base :
#endif
{}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
heap_base( heap_base&& rhs ) BOOST_NOEXCEPT_IF( boost::is_nothrow_move_constructible< Cmp >::value ) :
# ifndef BOOST_MSVC
heap_base( heap_base&& rhs ) noexcept( std::is_nothrow_move_constructible< Cmp >::value ) :
#ifndef BOOST_MSVC
Cmp( std::move( static_cast< Cmp& >( rhs ) ) ),
# endif
#endif
size_holder_type( std::move( static_cast< size_holder_type& >( rhs ) ) )
# ifdef BOOST_MSVC
#ifdef BOOST_MSVC
,
cmp_( std::move( rhs.cmp_ ) )
# endif
#endif
{}
heap_base( heap_base const& rhs ) :
# ifndef BOOST_MSVC
#ifndef BOOST_MSVC
Cmp( static_cast< Cmp const& >( rhs ) ),
# endif
#endif
size_holder_type( static_cast< size_holder_type const& >( rhs ) )
# ifdef BOOST_MSVC
#ifdef BOOST_MSVC
,
cmp_( rhs.value_comp() )
# endif
#endif
{}
heap_base& operator=( heap_base&& rhs ) BOOST_NOEXCEPT_IF( boost::is_nothrow_move_assignable< Cmp >::value )
heap_base& operator=( heap_base&& rhs ) noexcept( std::is_nothrow_move_assignable< Cmp >::value )
{
value_comp_ref().operator=( std::move( rhs.value_comp_ref() ) );
size_holder_type::operator=( std::move( static_cast< size_holder_type& >( rhs ) ) );
@@ -212,7 +208,6 @@ struct heap_base :
size_holder_type::operator=( static_cast< size_holder_type const& >( rhs ) );
return *this;
}
#endif
bool operator()( internal_type const& lhs, internal_type const& rhs ) const
{
@@ -224,32 +219,28 @@ struct heap_base :
return val;
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
T&& make_node( T&& val )
{
return std::forward< T >( val );
}
#endif
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
template < class... Args >
internal_type make_node( Args&&... val )
{
return internal_type( std::forward< Args >( val )... );
}
#endif
static T& get_value( internal_type& val ) BOOST_NOEXCEPT
static T& get_value( internal_type& val ) noexcept
{
return val;
}
static T const& get_value( internal_type const& val ) BOOST_NOEXCEPT
static T const& get_value( internal_type const& val ) noexcept
{
return val;
}
Cmp const& value_comp( void ) const BOOST_NOEXCEPT
Cmp const& value_comp( void ) const noexcept
{
#ifndef BOOST_MSVC
return *this;
@@ -258,24 +249,24 @@ struct heap_base :
#endif
}
Cmp const& get_internal_cmp( void ) const BOOST_NOEXCEPT
Cmp const& get_internal_cmp( void ) const noexcept
{
return value_comp();
}
void swap( heap_base& rhs ) BOOST_NOEXCEPT_IF(
boost::is_nothrow_move_constructible< Cmp >::value&& boost::is_nothrow_move_assignable< Cmp >::value )
void swap( heap_base& rhs ) noexcept( std::is_nothrow_move_constructible< Cmp >::value
&& std::is_nothrow_move_assignable< Cmp >::value )
{
std::swap( value_comp_ref(), rhs.value_comp_ref() );
size_holder< constant_time_size, size_t >::swap( rhs );
}
stability_counter_type get_stability_count( void ) const BOOST_NOEXCEPT
stability_counter_type get_stability_count( void ) const noexcept
{
return 0;
}
void set_stability_count( stability_counter_type ) BOOST_NOEXCEPT
void set_stability_count( stability_counter_type ) noexcept
{}
template < typename Heap1, typename Heap2 >
@@ -305,13 +296,11 @@ struct heap_base< T, Cmp, constant_time_size, StabilityCounterType, true > :
struct internal_type
{
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
template < class... Args >
internal_type( stability_counter_type cnt, Args&&... args ) :
first( std::forward< Args >( args )... ),
second( cnt )
{}
#endif
internal_type( stability_counter_type const& cnt, T const& value ) :
first( value ),
@@ -338,13 +327,12 @@ struct heap_base< T, Cmp, constant_time_size, StabilityCounterType, true > :
counter_( 0 )
{}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
heap_base( heap_base&& rhs ) BOOST_NOEXCEPT_IF( boost::is_nothrow_move_constructible< Cmp >::value ) :
# ifndef BOOST_MSVC
heap_base( heap_base&& rhs ) noexcept( std::is_nothrow_move_constructible< Cmp >::value ) :
#ifndef BOOST_MSVC
Cmp( std::move( static_cast< Cmp& >( rhs ) ) ),
# else
#else
cmp_( std::move( rhs.cmp_ ) ),
# endif
#endif
size_holder_type( std::move( static_cast< size_holder_type& >( rhs ) ) ),
counter_( rhs.counter_ )
{
@@ -352,16 +340,16 @@ struct heap_base< T, Cmp, constant_time_size, StabilityCounterType, true > :
}
heap_base( heap_base const& rhs ) :
# ifndef BOOST_MSVC
#ifndef BOOST_MSVC
Cmp( static_cast< Cmp const& >( rhs ) ),
# else
#else
cmp_( rhs.value_comp() ),
# endif
#endif
size_holder_type( static_cast< size_holder_type const& >( rhs ) ),
counter_( rhs.counter_ )
{}
heap_base& operator=( heap_base&& rhs ) BOOST_NOEXCEPT_IF( boost::is_nothrow_move_assignable< Cmp >::value )
heap_base& operator=( heap_base&& rhs ) noexcept( std::is_nothrow_move_assignable< Cmp >::value )
{
value_comp_ref().operator=( std::move( rhs.value_comp_ref() ) );
size_holder_type::operator=( std::move( static_cast< size_holder_type& >( rhs ) ) );
@@ -379,7 +367,6 @@ struct heap_base< T, Cmp, constant_time_size, StabilityCounterType, true > :
counter_ = rhs.counter_;
return *this;
}
#endif
bool operator()( internal_type const& lhs, internal_type const& rhs ) const
{
@@ -399,7 +386,6 @@ struct heap_base< T, Cmp, constant_time_size, StabilityCounterType, true > :
return internal_type( count, val );
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
template < class... Args >
internal_type make_node( Args&&... args )
{
@@ -408,19 +394,18 @@ struct heap_base< T, Cmp, constant_time_size, StabilityCounterType, true > :
BOOST_THROW_EXCEPTION( std::runtime_error( "boost::heap counter overflow" ) );
return internal_type( count, std::forward< Args >( args )... );
}
#endif
static T& get_value( internal_type& val ) BOOST_NOEXCEPT
static T& get_value( internal_type& val ) noexcept
{
return val.first;
}
static T const& get_value( internal_type const& val ) BOOST_NOEXCEPT
static T const& get_value( internal_type const& val ) noexcept
{
return val.first;
}
Cmp const& value_comp( void ) const BOOST_NOEXCEPT
Cmp const& value_comp( void ) const noexcept
{
#ifndef BOOST_MSVC
return *this;
@@ -452,8 +437,8 @@ struct heap_base< T, Cmp, constant_time_size, StabilityCounterType, true > :
return internal_compare( value_comp() );
}
void swap( heap_base& rhs ) BOOST_NOEXCEPT_IF(
boost::is_nothrow_move_constructible< Cmp >::value&& boost::is_nothrow_move_assignable< Cmp >::value )
void swap( heap_base& rhs ) noexcept( std::is_nothrow_move_constructible< Cmp >::value
&& std::is_nothrow_move_assignable< Cmp >::value )
{
#ifndef BOOST_MSVC
std::swap( static_cast< Cmp& >( *this ), static_cast< Cmp& >( rhs ) );
@@ -478,7 +463,7 @@ struct heap_base< T, Cmp, constant_time_size, StabilityCounterType, true > :
friend struct heap_merge_emulate;
private:
Cmp& value_comp_ref( void ) BOOST_NOEXCEPT
Cmp& value_comp_ref( void ) noexcept
{
#ifndef BOOST_MSVC
return *this;
+6 -6
View File
@@ -23,12 +23,12 @@ namespace boost { namespace heap { namespace detail {
template < typename type >
struct identity
{
type& operator()( type& x ) const BOOST_NOEXCEPT
type& operator()( type& x ) const noexcept
{
return x;
}
const type& operator()( const type& x ) const BOOST_NOEXCEPT
const type& operator()( const type& x ) const noexcept
{
return x;
}
@@ -120,7 +120,7 @@ struct ordered_tree_iterator_storage : ValueExtractor
return data_.top();
}
bool empty( void ) const BOOST_NOEXCEPT
bool empty( void ) const noexcept
{
return data_.empty();
}
@@ -165,7 +165,7 @@ class tree_iterator :
friend class boost::iterator_core_access;
typedef typename boost::conditional<
typedef typename std::conditional<
ordered_iterator,
ordered_tree_iterator_storage< ValueType, const Node*, Alloc, ValueCompare, ValueExtractor >,
unordered_tree_iterator_storage< const Node*, Alloc, ValueCompare > >::type unvisited_node_container;
@@ -246,7 +246,7 @@ private:
{
for ( typename Node::const_child_iterator it = n->children.begin(); it != n->children.end(); ++it ) {
const Node* n = PointerExtractor::operator()( it );
if ( check_null_pointer && n == NULL )
if ( check_null_pointer && n == nullptr )
continue;
unvisited_nodes.push( n );
}
@@ -312,7 +312,7 @@ public:
++next;
while ( true ) {
if ( parent == NULL || next != parent->children.end() )
if ( parent == nullptr || next != parent->children.end() )
break;
next = IteratorCoverter::operator()( parent );
+17 -23
View File
@@ -10,9 +10,10 @@
#define BOOST_HEAP_FIBONACCI_HEAP_HPP
#include <algorithm>
#include <array>
#include <type_traits>
#include <utility>
#include <boost/array.hpp>
#include <boost/assert.hpp>
#include <boost/heap/detail/heap_comparison.hpp>
@@ -48,7 +49,7 @@ template < typename T, typename Parspec >
struct make_fibonacci_heap_base
{
static const bool constant_time_size
= parameter::binding< Parspec, tag::constant_time_size, boost::true_type >::type::value;
= parameter::binding< Parspec, tag::constant_time_size, std::true_type >::type::value;
typedef typename detail::make_heap_base< T, Parspec, constant_time_size >::type base_type;
typedef typename detail::make_heap_base< T, Parspec, constant_time_size >::allocator_argument allocator_argument;
@@ -79,7 +80,6 @@ struct make_fibonacci_heap_base
return *this;
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
type( type&& rhs ) :
base_type( std::move( static_cast< base_type& >( rhs ) ) ),
allocator_type( std::move( static_cast< allocator_type& >( rhs ) ) )
@@ -91,7 +91,6 @@ struct make_fibonacci_heap_base
allocator_type::operator=( std::move( static_cast< allocator_type& >( rhs ) ) );
return *this;
}
#endif
};
};
@@ -237,14 +236,13 @@ public:
size_holder::set_size( rhs.size() );
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
/// \copydoc boost::heap::priority_queue::priority_queue(priority_queue &&)
fibonacci_heap( fibonacci_heap&& rhs ) :
super_t( std::move( rhs ) ),
top_element( rhs.top_element )
{
roots.splice( roots.begin(), rhs.roots );
rhs.top_element = NULL;
rhs.top_element = nullptr;
}
/// \copydoc boost::heap::priority_queue::operator=(priority_queue &&)
@@ -255,10 +253,9 @@ public:
super_t::operator=( std::move( rhs ) );
roots.splice( roots.begin(), rhs.roots );
top_element = rhs.top_element;
rhs.top_element = NULL;
rhs.top_element = nullptr;
return *this;
}
#endif
/// \copydoc boost::heap::priority_queue::operator=(priority_queue const &)
fibonacci_heap& operator=( fibonacci_heap const& rhs )
@@ -268,7 +265,7 @@ public:
static_cast< super_t& >( *this ) = rhs;
if ( rhs.empty() )
top_element = NULL;
top_element = nullptr;
else
clone_forest( rhs );
return *this;
@@ -314,7 +311,7 @@ public:
roots.clear_and_dispose( disposer( *this ) );
size_holder::set_size( 0 );
top_element = NULL;
top_element = nullptr;
}
/// \copydoc boost::heap::priority_queue::get_allocator
@@ -362,7 +359,6 @@ public:
return handle_type( n );
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
/**
* \b Effects: Adds a new element to the priority queue. The element is directly constructed in-place. Returns
* handle to element.
@@ -386,7 +382,6 @@ public:
top_element = n;
return handle_type( n );
}
#endif
/**
* \b Effects: Removes the top element from the priority queue.
@@ -453,7 +448,7 @@ public:
node_pointer parent = n->get_parent();
if ( parent ) {
n->parent = NULL;
n->parent = nullptr;
roots.splice( roots.begin(), parent->children, node_list_type::s_iterator_to( *n ) );
}
add_children_to_root( n );
@@ -575,7 +570,7 @@ public:
* */
ordered_iterator ordered_end( void ) const
{
return ordered_iterator( NULL, super_t::value_comp() );
return ordered_iterator( nullptr, super_t::value_comp() );
}
/**
@@ -593,7 +588,7 @@ public:
roots.splice( roots.end(), rhs.roots );
rhs.top_element = NULL;
rhs.top_element = nullptr;
rhs.set_size( 0 );
super_t::set_stability_count( ( std::max )( super_t::get_stability_count(), rhs.get_stability_count() ) );
@@ -661,7 +656,7 @@ private:
{
BOOST_HEAP_ASSERT( roots.empty() );
typedef typename node::template node_cloner< allocator_type > node_cloner;
roots.clone_from( rhs.roots, node_cloner( *this, NULL ), detail::nop_disposer() );
roots.clone_from( rhs.roots, node_cloner( *this, nullptr ), detail::nop_disposer() );
top_element
= detail::find_max_child< node_list_type, node, internal_compare >( roots, super_t::get_internal_cmp() );
@@ -704,9 +699,8 @@ private:
if ( roots.empty() )
return;
static const size_type max_log2 = sizeof( size_type ) * 8;
boost::array< node_pointer, max_log2 > aux;
aux.assign( NULL );
static const size_type max_log2 = sizeof( size_type ) * 8;
std::array< node_pointer, max_log2 > aux {};
node_list_iterator it = roots.begin();
top_element = static_cast< node_pointer >( &*it );
@@ -716,7 +710,7 @@ private:
++it;
size_type node_rank = n->child_count();
if ( aux[ node_rank ] == NULL )
if ( aux[ node_rank ] == nullptr )
aux[ node_rank ] = n;
else {
do {
@@ -733,9 +727,9 @@ private:
other->parent = n;
aux[ node_rank ] = NULL;
aux[ node_rank ] = nullptr;
node_rank = n->child_count();
} while ( aux[ node_rank ] != NULL );
} while ( aux[ node_rank ] != nullptr );
aux[ node_rank ] = n;
}
@@ -756,7 +750,7 @@ private:
if ( !empty() )
consolidate();
else
top_element = NULL;
top_element = nullptr;
}
mutable node_pointer top_element;
+8 -9
View File
@@ -10,11 +10,10 @@
#define BOOST_HEAP_MERGE_HPP
#include <algorithm>
#include <type_traits>
#include <boost/concept/assert.hpp>
#include <boost/heap/heap_concepts.hpp>
#include <boost/type_traits/conditional.hpp>
#include <boost/type_traits/is_same.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
@@ -41,7 +40,7 @@ struct heap_merge_emulate
}
};
typedef typename boost::conditional< Heap1::has_reserve, reserver, dummy_reserver >::type space_reserver;
typedef typename std::conditional< Heap1::has_reserve, reserver, dummy_reserver >::type space_reserver;
static void merge( Heap1& lhs, Heap2& rhs )
{
@@ -83,7 +82,7 @@ struct heap_merge_same
{
static const bool is_mergable = Heap::is_mergable;
typedef
typename boost::conditional< is_mergable, heap_merge_same_mergable< Heap >, heap_merge_emulate< Heap, Heap > >::type
typename std::conditional< is_mergable, heap_merge_same_mergable< Heap >, heap_merge_emulate< Heap, Heap > >::type
heap_merger;
static void merge( Heap& lhs, Heap& rhs )
@@ -107,13 +106,13 @@ void heap_merge( Heap1& lhs, Heap2& rhs )
BOOST_CONCEPT_ASSERT( (boost::heap::PriorityQueue< Heap2 >));
// if this assertion is triggered, the value_compare types are incompatible
BOOST_STATIC_ASSERT( ( boost::is_same< typename Heap1::value_compare, typename Heap2::value_compare >::value ) );
BOOST_STATIC_ASSERT( ( std::is_same< typename Heap1::value_compare, typename Heap2::value_compare >::value ) );
const bool same_heaps = boost::is_same< Heap1, Heap2 >::value;
const bool same_heaps = std::is_same< Heap1, Heap2 >::value;
typedef typename boost::conditional< same_heaps,
detail::heap_merge_same< Heap1 >,
detail::heap_merge_emulate< Heap1, Heap2 > >::type heap_merger;
typedef typename std::conditional< same_heaps,
detail::heap_merge_same< Heap1 >,
detail::heap_merge_emulate< Heap1, Heap2 > >::type heap_merger;
heap_merger::merge( lhs, rhs );
}
+15 -21
View File
@@ -10,6 +10,7 @@
#define BOOST_HEAP_PAIRING_HEAP_HPP
#include <algorithm>
#include <type_traits>
#include <utility>
#include <boost/assert.hpp>
@@ -19,7 +20,6 @@
#include <boost/heap/detail/stable_heap.hpp>
#include <boost/heap/detail/tree_iterator.hpp>
#include <boost/heap/policies.hpp>
#include <boost/type_traits/integral_constant.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
@@ -48,7 +48,7 @@ template < typename T, typename Parspec >
struct make_pairing_heap_base
{
static const bool constant_time_size
= parameter::binding< Parspec, tag::constant_time_size, boost::true_type >::type::value;
= parameter::binding< Parspec, tag::constant_time_size, std::true_type >::type::value;
typedef typename detail::make_heap_base< T, Parspec, constant_time_size >::type base_type;
typedef typename detail::make_heap_base< T, Parspec, constant_time_size >::allocator_argument allocator_argument;
typedef typename detail::make_heap_base< T, Parspec, constant_time_size >::compare_argument compare_argument;
@@ -67,7 +67,6 @@ struct make_pairing_heap_base
allocator_type( arg )
{}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
type( type const& rhs ) :
base_type( rhs ),
allocator_type( rhs )
@@ -91,7 +90,6 @@ struct make_pairing_heap_base
allocator_type::operator=( static_cast< const allocator_type& >( rhs ) );
return *this;
}
#endif
};
};
@@ -228,19 +226,19 @@ public:
/// \copydoc boost::heap::priority_queue::priority_queue(value_compare const &)
explicit pairing_heap( value_compare const& cmp = value_compare() ) :
super_t( cmp ),
root( NULL )
root( nullptr )
{}
/// \copydoc boost::heap::priority_queue::priority_queue(allocator_type const &)
explicit pairing_heap( allocator_type const& alloc ) :
super_t( alloc ),
root( NULL )
root( nullptr )
{}
/// \copydoc boost::heap::priority_queue::priority_queue(priority_queue const &)
pairing_heap( pairing_heap const& rhs ) :
super_t( rhs ),
root( NULL )
root( nullptr )
{
if ( rhs.empty() )
return;
@@ -249,13 +247,12 @@ public:
size_holder::set_size( rhs.get_size() );
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
/// \copydoc boost::heap::priority_queue::priority_queue(priority_queue &&)
pairing_heap( pairing_heap&& rhs ) :
super_t( std::move( rhs ) ),
root( rhs.root )
{
rhs.root = NULL;
rhs.root = nullptr;
}
/// \copydoc boost::heap::priority_queue::operator=(priority_queue &&)
@@ -263,10 +260,9 @@ public:
{
super_t::operator=( std::move( rhs ) );
root = rhs.root;
rhs.root = NULL;
rhs.root = nullptr;
return *this;
}
#endif
/// \copydoc boost::heap::priority_queue::operator=(priority_queue const & rhs)
pairing_heap& operator=( pairing_heap const& rhs )
@@ -288,7 +284,7 @@ public:
/// \copydoc boost::heap::priority_queue::empty
bool empty( void ) const
{
return root == NULL;
return root == nullptr;
}
/// \copydoc boost::heap::binomial_heap::size
@@ -297,7 +293,7 @@ public:
if ( constant_time_size )
return size_holder::get_size();
if ( root == NULL )
if ( root == nullptr )
return 0;
else
return detail::count_nodes( root );
@@ -320,7 +316,7 @@ public:
root->~node();
allocator_type& alloc = *this;
alloc.deallocate( root, 1 );
root = NULL;
root = nullptr;
size_holder::set_size( 0 );
}
@@ -367,7 +363,6 @@ public:
return handle_type( n );
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
/**
* \b Effects: Adds a new element to the priority queue. The element is directly constructed in-place. Returns
* handle to element.
@@ -390,7 +385,6 @@ public:
merge_node( n );
return handle_type( n );
}
#endif
/**
* \b Effects: Removes the top element from the priority queue.
@@ -529,7 +523,7 @@ public:
if ( !n->children.empty() )
root = merge_node_list( n->children );
else
root = NULL;
root = nullptr;
}
size_holder::decrement();
@@ -559,7 +553,7 @@ public:
/// \copydoc boost::heap::fibonacci_heap::ordered_begin
ordered_iterator ordered_end( void ) const
{
return ordered_iterator( NULL, super_t::value_comp() );
return ordered_iterator( nullptr, super_t::value_comp() );
}
@@ -589,7 +583,7 @@ public:
size_holder::add( rhs.get_size() );
rhs.set_size( 0 );
rhs.root = NULL;
rhs.root = nullptr;
super_t::set_stability_count( ( std::max )( super_t::get_stability_count(), rhs.get_stability_count() ) );
rhs.set_stability_count( 0 );
@@ -647,7 +641,7 @@ private:
#if !defined( BOOST_DOXYGEN_INVOKED )
void clone_tree( pairing_heap const& rhs )
{
BOOST_HEAP_ASSERT( root == NULL );
BOOST_HEAP_ASSERT( root == nullptr );
if ( rhs.empty() )
return;
@@ -659,7 +653,7 @@ private:
void merge_node( node_pointer other )
{
BOOST_HEAP_ASSERT( other );
if ( root != NULL )
if ( root != nullptr )
root = merge_nodes( root, other );
else
root = other;
+13 -14
View File
@@ -15,9 +15,8 @@
#include <boost/parameter/name.hpp>
#include <boost/parameter/parameters.hpp>
#include <boost/parameter/template_keyword.hpp>
#include <boost/type_traits/conditional.hpp>
#include <boost/type_traits/integral_constant.hpp>
#include <boost/type_traits/is_void.hpp>
#include <type_traits>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
@@ -34,7 +33,7 @@ struct stable;
} // namespace tag
template < bool T >
struct stable : boost::parameter::template_keyword< tag::stable, boost::integral_constant< bool, T > >
struct stable : boost::parameter::template_keyword< tag::stable, std::integral_constant< bool, T > >
{};
namespace tag {
@@ -42,7 +41,7 @@ struct mutable_;
} // namespace tag
template < bool T >
struct mutable_ : boost::parameter::template_keyword< tag::mutable_, boost::integral_constant< bool, T > >
struct mutable_ : boost::parameter::template_keyword< tag::mutable_, std::integral_constant< bool, T > >
{};
@@ -52,7 +51,7 @@ struct constant_time_size;
template < bool T >
struct constant_time_size :
boost::parameter::template_keyword< tag::constant_time_size, boost::integral_constant< bool, T > >
boost::parameter::template_keyword< tag::constant_time_size, std::integral_constant< bool, T > >
{};
namespace tag {
@@ -61,7 +60,7 @@ struct store_parent_pointer;
template < bool T >
struct store_parent_pointer :
boost::parameter::template_keyword< tag::store_parent_pointer, boost::integral_constant< bool, T > >
boost::parameter::template_keyword< tag::store_parent_pointer, std::integral_constant< bool, T > >
{};
namespace tag {
@@ -69,7 +68,7 @@ struct arity;
} // namespace tag
template < unsigned int T >
struct arity : boost::parameter::template_keyword< tag::arity, boost::integral_constant< int, T > >
struct arity : boost::parameter::template_keyword< tag::arity, std::integral_constant< int, T > >
{};
namespace tag {
@@ -77,7 +76,7 @@ struct objects_per_page;
} // namespace tag
template < unsigned int T >
struct objects_per_page : boost::parameter::template_keyword< tag::objects_per_page, boost::integral_constant< int, T > >
struct objects_per_page : boost::parameter::template_keyword< tag::objects_per_page, std::integral_constant< int, T > >
{};
BOOST_PARAMETER_TEMPLATE_KEYWORD( stability_counter_type )
@@ -88,7 +87,7 @@ template < typename bound_args, typename tag_type >
struct has_arg
{
typedef typename boost::parameter::binding< bound_args, tag_type, void >::type type;
static const bool value = !boost::is_void< type >::value;
static const bool value = !std::is_void< type >::value;
};
template < typename bound_args >
@@ -97,7 +96,7 @@ struct extract_stable
static const bool has_stable = has_arg< bound_args, tag::stable >::value;
typedef
typename boost::conditional< has_stable, typename has_arg< bound_args, tag::stable >::type, boost::false_type >::type
typename std::conditional< has_stable, typename has_arg< bound_args, tag::stable >::type, std::false_type >::type
stable_t;
static const bool value = stable_t::value;
@@ -108,9 +107,9 @@ struct extract_mutable
{
static const bool has_mutable = has_arg< bound_args, tag::mutable_ >::value;
typedef typename boost::conditional< has_mutable,
typename has_arg< bound_args, tag::mutable_ >::type,
boost::false_type >::type mutable_t;
typedef
typename std::conditional< has_mutable, typename has_arg< bound_args, tag::mutable_ >::type, std::false_type >::type
mutable_t;
static const bool value = mutable_t::value;
};
+10 -17
View File
@@ -137,15 +137,13 @@ public:
q_( rhs.q_ )
{}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
/**
* \b Effects: C++11-style move constructor.
*
* \b Complexity: Constant.
*
* \b Note: Only available, if BOOST_NO_CXX11_RVALUE_REFERENCES is not defined
* */
priority_queue( priority_queue&& rhs ) BOOST_NOEXCEPT_IF( boost::is_nothrow_move_constructible< super_t >::value ) :
priority_queue( priority_queue&& rhs ) noexcept( std::is_nothrow_move_constructible< super_t >::value ) :
super_t( std::move( rhs ) ),
q_( std::move( rhs.q_ ) )
{}
@@ -155,16 +153,13 @@ public:
*
* \b Complexity: Constant.
*
* \b Note: Only available, if BOOST_NO_CXX11_RVALUE_REFERENCES is not defined
* */
priority_queue& operator=( priority_queue&& rhs )
BOOST_NOEXCEPT_IF( boost::is_nothrow_move_assignable< super_t >::value )
priority_queue& operator=( priority_queue&& rhs ) noexcept( std::is_nothrow_move_assignable< super_t >::value )
{
super_t::operator=( std::move( rhs ) );
q_ = std::move( rhs.q_ );
return *this;
}
#endif
/**
* \b Effects: Assigns priority queue from rhs.
@@ -185,7 +180,7 @@ public:
* \b Complexity: Constant.
*
* */
bool empty( void ) const BOOST_NOEXCEPT
bool empty( void ) const noexcept
{
return q_.empty();
}
@@ -196,7 +191,7 @@ public:
* \b Complexity: Constant.
*
* */
size_type size( void ) const BOOST_NOEXCEPT
size_type size( void ) const noexcept
{
return q_.size();
}
@@ -207,7 +202,7 @@ public:
* \b Complexity: Constant.
*
* */
size_type max_size( void ) const BOOST_NOEXCEPT
size_type max_size( void ) const noexcept
{
return q_.max_size();
}
@@ -218,7 +213,7 @@ public:
* \b Complexity: Linear.
*
* */
void clear( void ) BOOST_NOEXCEPT
void clear( void ) noexcept
{
q_.clear();
}
@@ -258,7 +253,6 @@ public:
std::push_heap( q_.begin(), q_.end(), static_cast< super_t const& >( *this ) );
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
/**
* \b Effects: Adds a new element to the priority queue. The element is directly constructed in-place.
*
@@ -271,7 +265,6 @@ public:
q_.emplace_back( super_t::make_node( std::forward< Args >( args )... ) );
std::push_heap( q_.begin(), q_.end(), static_cast< super_t const& >( *this ) );
}
#endif
/**
* \b Effects: Removes the top element from the priority queue.
@@ -292,8 +285,8 @@ public:
* \b Complexity: Constant.
*
* */
void swap( priority_queue& rhs ) BOOST_NOEXCEPT_IF(
boost::is_nothrow_move_constructible< super_t >::value&& boost::is_nothrow_move_assignable< super_t >::value )
void swap( priority_queue& rhs ) noexcept( std::is_nothrow_move_constructible< super_t >::value
&& std::is_nothrow_move_assignable< super_t >::value )
{
super_t::swap( rhs );
q_.swap( rhs.q_ );
@@ -305,7 +298,7 @@ public:
* \b Complexity: Constant.
*
* */
iterator begin( void ) const BOOST_NOEXCEPT
iterator begin( void ) const noexcept
{
return iterator( q_.begin() );
}
@@ -316,7 +309,7 @@ public:
* \b Complexity: Constant.
*
* */
iterator end( void ) const BOOST_NOEXCEPT
iterator end( void ) const noexcept
{
return iterator( q_.end() );
}
+39 -53
View File
@@ -10,16 +10,16 @@
#define BOOST_HEAP_SKEW_HEAP_HPP
#include <algorithm>
#include <array>
#include <type_traits>
#include <utility>
#include <boost/array.hpp>
#include <boost/assert.hpp>
#include <boost/heap/detail/heap_comparison.hpp>
#include <boost/heap/detail/heap_node.hpp>
#include <boost/heap/detail/stable_heap.hpp>
#include <boost/heap/detail/tree_iterator.hpp>
#include <boost/type_traits/integral_constant.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
@@ -40,7 +40,7 @@ template < typename node_pointer, bool store_parent_pointer >
struct parent_holder
{
parent_holder( void ) :
parent_( NULL )
parent_( nullptr )
{}
void set_parent( node_pointer parent )
@@ -65,7 +65,7 @@ struct parent_holder< node_pointer, false >
node_pointer get_parent( void ) const
{
return NULL;
return nullptr;
}
};
@@ -75,23 +75,21 @@ struct skew_heap_node : parent_holder< skew_heap_node< value_type, store_parent_
{
typedef parent_holder< skew_heap_node< value_type, store_parent_pointer >*, store_parent_pointer > super_t;
typedef boost::array< skew_heap_node*, 2 > child_list_type;
typedef std::array< skew_heap_node*, 2 > child_list_type;
typedef typename child_list_type::iterator child_iterator;
typedef typename child_list_type::const_iterator const_child_iterator;
skew_heap_node( value_type const& v ) :
value( v )
{
children.assign( 0 );
children.fill( 0 );
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
skew_heap_node( value_type&& v ) :
value( v )
{
children.assign( 0 );
children.fill( 0 );
}
#endif
template < typename Alloc >
skew_heap_node( skew_heap_node const& rhs, Alloc& allocator, skew_heap_node* parent ) :
@@ -109,7 +107,7 @@ struct skew_heap_node : parent_holder< skew_heap_node< value_type, store_parent_
if ( rhs.children[ index ] )
children[ index ] = cloner( *rhs.children[ index ], this );
else
children[ index ] = NULL;
children[ index ] = nullptr;
}
template < typename Alloc >
@@ -144,7 +142,7 @@ struct skew_heap_node : parent_holder< skew_heap_node< value_type, store_parent_
for ( const_child_iterator it = children.begin(); it != children.end(); ++it ) {
const skew_heap_node* child = *it;
if ( child == NULL )
if ( child == nullptr )
continue;
if ( store_parent_pointer )
@@ -157,8 +155,8 @@ struct skew_heap_node : parent_holder< skew_heap_node< value_type, store_parent_
return true;
}
value_type value;
boost::array< skew_heap_node*, 2 > children;
value_type value;
std::array< skew_heap_node*, 2 > children;
};
@@ -175,7 +173,7 @@ template < typename T, typename BoundArgs >
struct make_skew_heap_base
{
static const bool constant_time_size
= parameter::binding< BoundArgs, tag::constant_time_size, boost::true_type >::type::value;
= parameter::binding< BoundArgs, tag::constant_time_size, std::true_type >::type::value;
typedef typename make_heap_base< T, BoundArgs, constant_time_size >::type base_type;
typedef typename make_heap_base< T, BoundArgs, constant_time_size >::allocator_argument allocator_argument;
@@ -199,7 +197,6 @@ struct make_skew_heap_base
allocator_type( arg )
{}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
type( type&& rhs ) :
base_type( std::move( static_cast< base_type& >( rhs ) ) ),
allocator_type( std::move( static_cast< allocator_type& >( rhs ) ) )
@@ -223,7 +220,6 @@ struct make_skew_heap_base
allocator_type::operator=( static_cast< allocator_type const& >( rhs ) );
return *this;
}
#endif
};
};
@@ -288,10 +284,10 @@ class skew_heap :
typedef detail::value_extractor< value_type, internal_type, super_t > value_extractor;
typedef boost::array< node_pointer, 2 > child_list_type;
typedef std::array< node_pointer, 2 > child_list_type;
typedef typename child_list_type::iterator child_list_iterator;
typedef typename boost::conditional<
typedef typename std::conditional<
false,
detail::recursive_tree_iterator< node,
child_list_iterator,
@@ -346,12 +342,12 @@ public:
static const bool is_mutable = detail::extract_mutable< bound_args >::value;
typedef
typename boost::conditional< is_mutable, typename implementation_defined::handle_type, void* >::type handle_type;
typename std::conditional< is_mutable, typename implementation_defined::handle_type, void* >::type handle_type;
/// \copydoc boost::heap::priority_queue::priority_queue(value_compare const &)
explicit skew_heap( value_compare const& cmp = value_compare() ) :
super_t( cmp ),
root( NULL )
root( nullptr )
{}
/// \copydoc boost::heap::priority_queue::priority_queue(allocator_type const &)
@@ -383,13 +379,12 @@ public:
return *this;
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
/// \copydoc boost::heap::priority_queue::priority_queue(priority_queue &&)
skew_heap( skew_heap&& rhs ) :
super_t( std::move( rhs ) ),
root( rhs.root )
{
rhs.root = NULL;
rhs.root = nullptr;
}
/// \copydoc boost::heap::priority_queue::operator=(priority_queue &&)
@@ -397,10 +392,9 @@ public:
{
super_t::operator=( std::move( rhs ) );
root = rhs.root;
rhs.root = NULL;
rhs.root = nullptr;
return *this;
}
#endif
~skew_heap( void )
{
@@ -413,13 +407,12 @@ public:
* \b Complexity: Logarithmic (amortized).
*
* */
typename boost::conditional< is_mutable, handle_type, void >::type push( value_type const& v )
typename std::conditional< is_mutable, handle_type, void >::type push( value_type const& v )
{
typedef typename boost::conditional< is_mutable, push_handle, push_void >::type push_helper;
typedef typename std::conditional< is_mutable, push_handle, push_void >::type push_helper;
return push_helper::push( this, v );
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
/**
* \b Effects: Adds a new element to the priority queue. The element is directly constructed in-place.
*
@@ -427,17 +420,16 @@ public:
*
* */
template < typename... Args >
typename boost::conditional< is_mutable, handle_type, void >::type emplace( Args&&... args )
typename std::conditional< is_mutable, handle_type, void >::type emplace( Args&&... args )
{
typedef typename boost::conditional< is_mutable, push_handle, push_void >::type push_helper;
typedef typename std::conditional< is_mutable, push_handle, push_void >::type push_helper;
return push_helper::emplace( this, std::forward< Args >( args )... );
}
#endif
/// \copydoc boost::heap::priority_queue::empty
bool empty( void ) const
{
return root == NULL;
return root == nullptr;
}
/// \copydoc boost::heap::binomial_heap::size
@@ -446,7 +438,7 @@ public:
if ( constant_time_size )
return size_holder::get_size();
if ( root == NULL )
if ( root == nullptr )
return 0;
else
return root->count_children();
@@ -469,7 +461,7 @@ public:
root->~node();
allocator_type& alloc = *this;
alloc.deallocate( root, 1 );
root = NULL;
root = nullptr;
size_holder::set_size( 0 );
}
@@ -510,7 +502,7 @@ public:
size_holder::decrement();
if ( root )
BOOST_HEAP_ASSERT( root->get_parent() == NULL );
BOOST_HEAP_ASSERT( root->get_parent() == nullptr );
else
BOOST_HEAP_ASSERT( size_holder::get_size() == 0 );
@@ -559,7 +551,7 @@ public:
size_holder::add( rhs.get_size() );
rhs.set_size( 0 );
rhs.root = NULL;
rhs.root = nullptr;
sanity_check();
super_t::set_stability_count( ( std::max )( super_t::get_stability_count(), rhs.get_stability_count() ) );
@@ -710,11 +702,11 @@ public:
node_pointer parent = this_node->get_parent();
if ( this_node == parent->children[ 0 ] )
parent->children[ 0 ] = NULL;
parent->children[ 0 ] = nullptr;
else
parent->children[ 1 ] = NULL;
parent->children[ 1 ] = nullptr;
this_node->set_parent( NULL );
this_node->set_parent( nullptr );
merge_node( this_node );
}
@@ -746,8 +738,8 @@ public:
node_pointer this_node = handle.node_;
unlink_node( this_node );
this_node->children.assign( 0 );
this_node->set_parent( NULL );
this_node->children.fill( 0 );
this_node->set_parent( nullptr );
merge_node( this_node );
}
@@ -760,13 +752,11 @@ private:
self->push_internal( v );
}
# if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
template < class... Args >
static void emplace( skew_heap* self, Args&&... args )
{
self->emplace_internal( std::forward< Args >( args )... );
}
# endif
};
struct push_handle
@@ -776,13 +766,11 @@ private:
return handle_type( self->push_internal( v ) );
}
# if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
template < class... Args >
static handle_type emplace( skew_heap* self, Args&&... args )
{
return handle_type( self->emplace_internal( std::forward< Args >( args )... ) );
}
# endif
};
node_pointer push_internal( const_reference v )
@@ -796,7 +784,6 @@ private:
return n;
}
# if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
template < class... Args >
node_pointer emplace_internal( Args&&... args )
{
@@ -808,7 +795,6 @@ private:
merge_node( n );
return n;
}
# endif
void unlink_node( node_pointer node )
{
@@ -826,32 +812,32 @@ private:
void clone_tree( skew_heap const& rhs )
{
BOOST_HEAP_ASSERT( root == NULL );
BOOST_HEAP_ASSERT( root == nullptr );
if ( rhs.empty() )
return;
allocator_type& alloc = *this;
root = alloc.allocate( 1 );
new ( root ) node( *rhs.root, alloc, NULL );
new ( root ) node( *rhs.root, alloc, nullptr );
}
void merge_node( node_pointer other )
{
BOOST_HEAP_ASSERT( other );
if ( root != NULL )
root = merge_nodes( root, other, NULL );
if ( root != nullptr )
root = merge_nodes( root, other, nullptr );
else
root = other;
}
node_pointer merge_nodes( node_pointer node1, node_pointer node2, node_pointer new_parent )
{
if ( node1 == NULL ) {
if ( node1 == nullptr ) {
if ( node2 )
node2->set_parent( new_parent );
return node2;
}
if ( node2 == NULL ) {
if ( node2 == nullptr ) {
node1->set_parent( new_parent );
return node1;
}
@@ -901,7 +887,7 @@ private:
size_type stored_size = size_holder::get_size();
size_type counted_size;
if ( root == NULL )
if ( root == nullptr )
counted_size = 0;
else
counted_size = root->count_children();
-1
View File
@@ -44,7 +44,6 @@ foreach(Test ${Tests})
set (Libs Boost::heap
Boost::unit_test_framework
Boost::container
Boost::foreach
boost_heap_test_common)
source_group( TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${Test}.cpp)
-1
View File
@@ -34,7 +34,6 @@ rule test_all
: # test-files
: <library>/boost/test//boost_unit_test_framework # requirements
<library>/boost/container//boost_container
<library>/boost/foreach//boost_foreach
] ;
}
}
+8 -22
View File
@@ -78,7 +78,6 @@ void fill_q( pri_queue& q, data_container const& data )
q.push( data[ i ] );
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
template < typename pri_queue, typename data_container >
void fill_emplace_q( pri_queue& q, data_container const& data )
{
@@ -87,7 +86,6 @@ void fill_emplace_q( pri_queue& q, data_container const& data )
q.emplace( std::move( value ) );
}
}
#endif
template < typename pri_queue >
void pri_queue_test_sequential_push( void )
@@ -116,7 +114,6 @@ void pri_queue_test_sequential_reverse_push( void )
template < typename pri_queue >
void pri_queue_test_emplace( void )
{
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
for ( int i = 0; i != test_size; ++i ) {
pri_queue q;
test_data data = make_test_data( i );
@@ -125,7 +122,6 @@ void pri_queue_test_emplace( void )
std::reverse( data.begin(), data.end() );
check_q( q, data );
}
#endif
}
@@ -177,7 +173,6 @@ void pri_queue_test_assignment( void )
template < typename pri_queue >
void pri_queue_test_moveconstructor( void )
{
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
pri_queue q;
test_data data = make_test_data( test_size );
fill_q( q, data );
@@ -186,13 +181,11 @@ void pri_queue_test_moveconstructor( void )
check_q( r, data );
BOOST_REQUIRE( q.empty() );
#endif
}
template < typename pri_queue >
void pri_queue_test_move_assignment( void )
{
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
pri_queue q;
test_data data = make_test_data( test_size );
fill_q( q, data );
@@ -202,7 +195,6 @@ void pri_queue_test_move_assignment( void )
check_q( r, data );
BOOST_REQUIRE( q.empty() );
#endif
}
@@ -475,8 +467,6 @@ struct less_with_T
};
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
class thing
{
public:
@@ -505,18 +495,14 @@ public:
}
};
# define RUN_EMPLACE_TEST( HEAP_TYPE ) \
do { \
cmpthings ord; \
boost::heap::HEAP_TYPE< thing, boost::heap::compare< cmpthings > > vpq( ord ); \
vpq.emplace( 5, 6, 7 ); \
boost::heap::HEAP_TYPE< thing, boost::heap::compare< cmpthings >, boost::heap::stable< true > > vpq2( ord ); \
vpq2.emplace( 5, 6, 7 ); \
} while ( 0 );
#else
# define RUN_EMPLACE_TEST( HEAP_TYPE )
#endif
#define RUN_EMPLACE_TEST( HEAP_TYPE ) \
do { \
cmpthings ord; \
boost::heap::HEAP_TYPE< thing, boost::heap::compare< cmpthings > > vpq( ord ); \
vpq.emplace( 5, 6, 7 ); \
boost::heap::HEAP_TYPE< thing, boost::heap::compare< cmpthings >, boost::heap::stable< true > > vpq2( ord ); \
vpq2.emplace( 5, 6, 7 ); \
} while ( 0 );
#endif // COMMON_HEAP_TESTS_HPP_INCLUDED
-2
View File
@@ -51,12 +51,10 @@ void run_d_ary_heap_test( void )
run_stable_heap_tests< stable_pri_queue >();
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) && !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
cmpthings ord;
boost::heap::d_ary_heap< thing, boost::heap::arity< D >, boost::heap::compare< cmpthings >, boost::heap::stable< stable > >
vpq( ord );
vpq.emplace( 5, 6, 7 );
#endif
}
+1 -1
View File
@@ -64,7 +64,7 @@ struct pri_queue_test_heap_merge
template < typename pri_queue >
void run_merge_tests( void )
{
boost::conditional< pri_queue::is_mergable, pri_queue_test_merge< pri_queue >, dummy_run >::type::run();
std::conditional< pri_queue::is_mergable, pri_queue_test_merge< pri_queue >, dummy_run >::type::run();
pri_queue_test_heap_merge< pri_queue, pri_queue >::run();
}
-1
View File
@@ -7,7 +7,6 @@
=============================================================================*/
#include "common_heap_tests.hpp"
#include <boost/foreach.hpp>
struct q_tester
{