Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion 26 Framework/Foundation/include/Framework/Pack.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,20 @@ template <typename P1, typename P2, typename... Ps>
constexpr auto concatenate_pack(P1 p1, P2 p2, Ps... ps)
{
return concatenate_pack(p1, concatenate_pack(p2, ps...));
};
}

template <typename... Ps>
using concatenated_pack_t = decltype(concatenate_pack(Ps{}...));

template <typename... Args1, typename... Args2>
constexpr auto interleave_pack(pack<Args1...>, pack<Args2...>)
{
return concatenated_pack_t<pack<Args1, Args2>...>{};
}

template <typename P1, typename P2>
using interleaved_pack_t = decltype(interleave_pack(P1{}, P2{}));

/// Selects from the pack types that satisfy the Condition
template <template <typename> typename Condition, typename Result>
constexpr auto select_pack(Result result, pack<>)
Expand Down Expand Up @@ -248,6 +257,21 @@ constexpr auto concatenate_pack_unique(P1 p1, P2 p2, Ps... ps)
template <typename... Ps>
using concatenated_pack_unique_t = decltype(concatenate_pack_unique(Ps{}...));

template <typename PT>
constexpr auto unique_pack(pack<>, PT p2)
{
return p2;
}

template <typename PT, typename T, typename... Ts>
constexpr auto unique_pack(pack<T, Ts...>, PT p2)
{
return unique_pack(pack<Ts...>{}, concatenate_pack_unique(pack<T>{}, p2));
}

template <typename P>
using unique_pack_t = decltype(unique_pack(P{}, pack<>{}));

} // namespace o2::framework

#endif // O2_FRAMEWORK_PACK_H_
3 changes: 3 additions & 0 deletions 3 Framework/Foundation/test/test_FunctionalHelpers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ BOOST_AUTO_TEST_CASE(TestOverride)
print_pack<p3>();
static_assert(std::is_same_v<p3, pack<float, bool, int, double, char>>, "pack should not have duplicated types");

static_assert(std::is_same_v<unique_pack_t<pack<int, float, int, float, char, char>>, pack<char, float, int>>, "pack should not have duplicated types");
static_assert(std::is_same_v<interleaved_pack_t<pack<int, float, int>, pack<char, bool, char>>, pack<int, char, float, bool, int, char>>, "interleaved packs of the same size");

struct ForwardDeclared;
static_assert(is_type_complete_v<ForwardDeclared> == false, "This should not be complete because the struct is simply forward declared.");

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.