Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
StellarBot
committed
Jun 28, 2017
1 parent
d8e979b
commit e1d8a74
Showing
572 changed files
with
4,563 additions
and
4,262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright (c) 2017 Denis Blank | ||
// | ||
// 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) | ||
|
||
#ifndef HPX_UTIL_PACK_TRAVERSAL_HPP | ||
#define HPX_UTIL_PACK_TRAVERSAL_HPP | ||
|
||
#include <hpx/util/detail/pack_traversal_impl.hpp> | ||
|
||
#include <utility> | ||
|
||
namespace hpx { | ||
namespace util { | ||
/// Maps the pack with the given mapper. | ||
/// | ||
/// This function tries to visit all plain elements which may be wrapped in: | ||
/// - homogeneous containers (`std::vector`, `std::list`) | ||
/// - heterogenous containers `(hpx::tuple`, `std::pair`, `std::array`) | ||
/// and re-assembles the pack with the result of the mapper. | ||
/// Mapping from one type to a different one is supported. | ||
/// | ||
/// Elements that aren't accepted by the mapper are routed through | ||
/// and preserved through the hierarchy. | ||
/// | ||
/// ```cpp | ||
/// // Maps all ints to floats | ||
/// map_pack([](int value) { | ||
/// return float(value); | ||
/// }, | ||
/// 1, hpx::util::make_tuple(2, std::vector<int>{3, 4}), 5); | ||
/// ``` | ||
/// | ||
/// \throws std::exception like objects which are thrown by an | ||
/// invocation to the mapper. | ||
/// | ||
/// \param mapper A callable object, which accept an arbitrary type | ||
/// and maps it to another type or the same one. | ||
/// | ||
/// \param pack An arbitrary variadic pack which may contain any type. | ||
/// | ||
/// \returns The mapped element or in case the pack contains | ||
/// multiple elements, the pack is wrapped into | ||
/// a `hpx::tuple`. | ||
/// | ||
template <typename Mapper, typename... T> | ||
auto map_pack(Mapper&& mapper, T&&... pack) | ||
-> decltype(detail::apply_pack_transform(detail::strategy_remap_tag{}, | ||
std::forward<Mapper>(mapper), | ||
std::forward<T>(pack)...)) | ||
{ | ||
return detail::apply_pack_transform(detail::strategy_remap_tag{}, | ||
std::forward<Mapper>(mapper), | ||
std::forward<T>(pack)...); | ||
} | ||
|
||
/// Traverses the pack with the given visitor. | ||
/// | ||
/// This function works in the same way as `map_pack`, | ||
/// however, the result of the mapper isn't preserved. | ||
/// | ||
/// See `map_pack` for a detailed description. | ||
template <typename Mapper, typename... T> | ||
void traverse_pack(Mapper&& mapper, T&&... pack) | ||
{ | ||
detail::apply_pack_transform(detail::strategy_traverse_tag{}, | ||
std::forward<Mapper>(mapper), | ||
std::forward<T>(pack)...); | ||
} | ||
} // end namespace util | ||
} // end namespace hpx | ||
|
||
#endif // HPX_UTIL_PACK_TRAVERSAL_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.