Skip to content
Snippets Groups Projects
Commit 4209d7ec authored by Dmitri Naumov's avatar Dmitri Naumov Committed by Dmitri Naumov
Browse files

[BL] sizesToOffsets() w/ last entry sum(sizes)

parent ebd8a07a
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,10 @@ ...@@ -16,6 +16,10 @@
#include <optional> #include <optional>
#include <range/v3/algorithm/find_if.hpp> #include <range/v3/algorithm/find_if.hpp>
#include <range/v3/range/concepts.hpp> #include <range/v3/range/concepts.hpp>
#include <range/v3/range/conversion.hpp>
#include <range/v3/view/concat.hpp>
#include <range/v3/view/partial_sum.hpp>
#include <range/v3/view/single.hpp>
#include <string> #include <string>
#include <typeindex> #include <typeindex>
#include <typeinfo> #include <typeinfo>
...@@ -272,6 +276,18 @@ void cleanupVectorElements(std::vector<T1*>& dependent_items, Args&&... args) ...@@ -272,6 +276,18 @@ void cleanupVectorElements(std::vector<T1*>& dependent_items, Args&&... args)
cleanupVectorElements(std::forward<Args>(args)...); cleanupVectorElements(std::forward<Args>(args)...);
} }
/// Converts range of sizes to a vector of offsets. First offset is 0 and the
/// resulting vector size is the size of the input range plus one.
template <ranges::range R>
requires std::is_integral_v<ranges::range_value_t<R>>
std::vector<ranges::range_value_t<R>> sizesToOffsets(R const& sizes)
{
return ranges::views::concat(
ranges::views::single(ranges::range_value_t<R>{0}),
ranges::views::partial_sum(sizes)) |
ranges::to<std::vector<ranges::range_value_t<R>>>();
}
/// Checks if any of the elements in the given list is true. /// Checks if any of the elements in the given list is true.
template <typename List> template <typename List>
constexpr bool any_of(List const& values) constexpr bool any_of(List const& values)
......
...@@ -12,6 +12,7 @@ target_link_libraries( ...@@ -12,6 +12,7 @@ target_link_libraries(
BaseLib BaseLib
PUBLIC Boost::algorithm PUBLIC Boost::algorithm
Boost::property_tree Boost::property_tree
range-v3
spdlog spdlog
tclap tclap
$<$<BOOL:${MSVC}>:WinMM> # needed for timeGetTime $<$<BOOL:${MSVC}>:WinMM> # needed for timeGetTime
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment