Skip to content

Commit

Permalink
Fixing all uninitialized* algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Jun 25, 2017
1 parent 5cd77b0 commit 83a63e8
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 153 deletions.
152 changes: 89 additions & 63 deletions hpx/parallel/algorithms/uninitialized_copy.hpp

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions hpx/parallel/algorithms/uninitialized_default_construct.hpp
Expand Up @@ -210,9 +210,7 @@ namespace hpx { namespace parallel { inline namespace v1
(hpx::traits::is_forward_iterator<FwdIter>::value),
"Required at least forward iterator.");

typedef std::integral_constant<bool,
execution::is_sequenced_execution_policy<ExPolicy>::value
> is_seq;
typedef execution::is_sequenced_execution_policy<ExPolicy> is_seq;

return detail::uninitialized_default_construct<FwdIter>().call(
std::forward<ExPolicy>(policy), is_seq(), first, last);
Expand Down Expand Up @@ -344,9 +342,7 @@ namespace hpx { namespace parallel { inline namespace v1
std::move(first));
}

typedef std::integral_constant<bool,
execution::is_sequenced_execution_policy<ExPolicy>::value
> is_seq;
typedef execution::is_sequenced_execution_policy<ExPolicy> is_seq;

return detail::uninitialized_default_construct_n<FwdIter>().call(
std::forward<ExPolicy>(policy), is_seq(),
Expand Down
22 changes: 15 additions & 7 deletions hpx/parallel/algorithms/uninitialized_fill.hpp
@@ -1,4 +1,4 @@
// Copyright (c) 2014-2016 Hartmut Kaiser
// Copyright (c) 2014-2017 Hartmut Kaiser
//
// 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)
Expand Down Expand Up @@ -162,9 +162,9 @@ namespace hpx { namespace parallel { inline namespace v1
/// It describes the manner in which the execution
/// of the algorithm may be parallelized and the manner
/// in which it executes the assignments.
/// \tparam InIter The type of the source iterators used (deduced).
/// \tparam FwdIter The type of the source iterators used (deduced).
/// This iterator type must meet the requirements of an
/// input iterator.
/// forward iterator.
/// \tparam T The type of the value to be assigned (deduced).
///
/// \param policy The execution policy to use for the scheduling of
Expand Down Expand Up @@ -192,22 +192,30 @@ namespace hpx { namespace parallel { inline namespace v1
/// \a parallel_task_policy and returns nothing
/// otherwise.
///
template <typename ExPolicy, typename InIter, typename T>
template <typename ExPolicy, typename FwdIter, typename T>
inline typename std::enable_if<
execution::is_execution_policy<ExPolicy>::value,
typename util::detail::algorithm_result<ExPolicy>::type
>::type
uninitialized_fill(ExPolicy && policy, InIter first, InIter last,
uninitialized_fill(ExPolicy && policy, FwdIter first, FwdIter last,
T const& value)
{
#if defined(HPX_HAVE_ALGORITHM_INPUT_ITERATOR_SUPPORT)
static_assert(
(hpx::traits::is_input_iterator<InIter>::value),
(hpx::traits::is_input_iterator<FwdIter>::value),
"Required at least input iterator.");

typedef std::integral_constant<bool,
execution::is_sequenced_execution_policy<ExPolicy>::value ||
!hpx::traits::is_forward_iterator<InIter>::value
!hpx::traits::is_forward_iterator<FwdIter>::value
> is_seq;
#else
static_assert(
(hpx::traits::is_forward_iterator<FwdIter>::value),
"Required at least forward iterator.");

typedef execution::is_sequenced_execution_policy<ExPolicy> is_seq;
#endif

return detail::uninitialized_fill().call(
std::forward<ExPolicy>(policy), is_seq(),
Expand Down
165 changes: 94 additions & 71 deletions hpx/parallel/algorithms/uninitialized_move.hpp

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions hpx/parallel/algorithms/uninitialized_value_construct.hpp
Expand Up @@ -211,9 +211,7 @@ namespace hpx { namespace parallel { inline namespace v1
(hpx::traits::is_forward_iterator<FwdIter>::value),
"Required at least forward iterator.");

typedef std::integral_constant<bool,
execution::is_sequenced_execution_policy<ExPolicy>::value
> is_seq;
typedef execution::is_sequenced_execution_policy<ExPolicy> is_seq;

return detail::uninitialized_value_construct<FwdIter>().call(
std::forward<ExPolicy>(policy), is_seq(), first, last);
Expand Down Expand Up @@ -347,9 +345,7 @@ namespace hpx { namespace parallel { inline namespace v1
std::move(first));
}

typedef std::integral_constant<bool,
execution::is_sequenced_execution_policy<ExPolicy>::value
> is_seq;
typedef execution::is_sequenced_execution_policy<ExPolicy> is_seq;

return detail::uninitialized_value_construct_n<FwdIter>().call(
std::forward<ExPolicy>(policy), is_seq(),
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/parallel/algorithms/uninitialized_copy.cpp
Expand Up @@ -43,7 +43,9 @@ void uninitialized_copy_test()
{
test_uninitialized_copy<std::random_access_iterator_tag>();
test_uninitialized_copy<std::forward_iterator_tag>();
#if defined(HPX_HAVE_ALGORITHM_INPUT_ITERATOR_SUPPORT)
test_uninitialized_copy<std::input_iterator_tag>();
#endif
}

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -82,7 +84,9 @@ void uninitialized_copy_exception_test()
{
test_uninitialized_copy_exception<std::random_access_iterator_tag>();
test_uninitialized_copy_exception<std::forward_iterator_tag>();
#if defined(HPX_HAVE_ALGORITHM_INPUT_ITERATOR_SUPPORT)
test_uninitialized_copy_exception<std::input_iterator_tag>();
#endif
}

//////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -121,7 +125,9 @@ void uninitialized_copy_bad_alloc_test()
{
test_uninitialized_copy_bad_alloc<std::random_access_iterator_tag>();
test_uninitialized_copy_bad_alloc<std::forward_iterator_tag>();
#if defined(HPX_HAVE_ALGORITHM_INPUT_ITERATOR_SUPPORT)
test_uninitialized_copy_bad_alloc<std::input_iterator_tag>();
#endif
}

int hpx_main(boost::program_options::variables_map& vm)
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/parallel/algorithms/uninitialized_copyn.cpp
Expand Up @@ -103,7 +103,9 @@ void uninitialized_copy_n_test()
{
test_uninitialized_copy_n<std::random_access_iterator_tag>();
test_uninitialized_copy_n<std::forward_iterator_tag>();
#if defined(HPX_HAVE_ALGORITHM_INPUT_ITERATOR_SUPPORT)
test_uninitialized_copy_n<std::input_iterator_tag>();
#endif
}

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -233,7 +235,9 @@ void uninitialized_copy_n_exception_test()
{
test_uninitialized_copy_n_exception<std::random_access_iterator_tag>();
test_uninitialized_copy_n_exception<std::forward_iterator_tag>();
#if defined(HPX_HAVE_ALGORITHM_INPUT_ITERATOR_SUPPORT)
test_uninitialized_copy_n_exception<std::input_iterator_tag>();
#endif
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -362,7 +366,9 @@ void uninitialized_copy_n_bad_alloc_test()
{
test_uninitialized_copy_n_bad_alloc<std::random_access_iterator_tag>();
test_uninitialized_copy_n_bad_alloc<std::forward_iterator_tag>();
#if defined(HPX_HAVE_ALGORITHM_INPUT_ITERATOR_SUPPORT)
test_uninitialized_copy_n_bad_alloc<std::input_iterator_tag>();
#endif
}

int hpx_main(boost::program_options::variables_map& vm)
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/parallel/algorithms/uninitialized_move.cpp
Expand Up @@ -43,7 +43,9 @@ void uninitialized_move_test()
{
test_uninitialized_move<std::random_access_iterator_tag>();
test_uninitialized_move<std::forward_iterator_tag>();
#if defined(HPX_HAVE_ALGORITHM_INPUT_ITERATOR_SUPPORT)
test_uninitialized_move<std::input_iterator_tag>();
#endif
}

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -82,7 +84,9 @@ void uninitialized_move_exception_test()
{
test_uninitialized_move_exception<std::random_access_iterator_tag>();
test_uninitialized_move_exception<std::forward_iterator_tag>();
#if defined(HPX_HAVE_ALGORITHM_INPUT_ITERATOR_SUPPORT)
test_uninitialized_move_exception<std::input_iterator_tag>();
#endif
}

//////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -121,7 +125,9 @@ void uninitialized_move_bad_alloc_test()
{
test_uninitialized_move_bad_alloc<std::random_access_iterator_tag>();
test_uninitialized_move_bad_alloc<std::forward_iterator_tag>();
#if defined(HPX_HAVE_ALGORITHM_INPUT_ITERATOR_SUPPORT)
test_uninitialized_move_bad_alloc<std::input_iterator_tag>();
#endif
}

int hpx_main(boost::program_options::variables_map& vm)
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/parallel/algorithms/uninitialized_moven.cpp
Expand Up @@ -103,7 +103,9 @@ void uninitialized_move_n_test()
{
test_uninitialized_move_n<std::random_access_iterator_tag>();
test_uninitialized_move_n<std::forward_iterator_tag>();
#if defined(HPX_HAVE_ALGORITHM_INPUT_ITERATOR_SUPPORT)
test_uninitialized_move_n<std::input_iterator_tag>();
#endif
}

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -233,7 +235,9 @@ void uninitialized_move_n_exception_test()
{
test_uninitialized_move_n_exception<std::random_access_iterator_tag>();
test_uninitialized_move_n_exception<std::forward_iterator_tag>();
#if defined(HPX_HAVE_ALGORITHM_INPUT_ITERATOR_SUPPORT)
test_uninitialized_move_n_exception<std::input_iterator_tag>();
#endif
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -362,7 +366,9 @@ void uninitialized_move_n_bad_alloc_test()
{
test_uninitialized_move_n_bad_alloc<std::random_access_iterator_tag>();
test_uninitialized_move_n_bad_alloc<std::forward_iterator_tag>();
#if defined(HPX_HAVE_ALGORITHM_INPUT_ITERATOR_SUPPORT)
test_uninitialized_move_n_bad_alloc<std::input_iterator_tag>();
#endif
}

int hpx_main(boost::program_options::variables_map& vm)
Expand Down

0 comments on commit 83a63e8

Please sign in to comment.