Skip to content
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
9 changes: 8 additions & 1 deletion include/podio/RelationRange.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef PODIO_RELATIONRANGE_H
#define PODIO_RELATIONRANGE_H

#include <iterator>
#include <ranges>
#include <vector>

namespace podio {
Expand Down Expand Up @@ -57,4 +57,11 @@ class RelationRange {
};
} // namespace podio

// Opt-in to view concept
template <typename ReferenceType>
inline constexpr bool std::ranges::enable_view<podio::RelationRange<ReferenceType>> = true;
// Opt-in to borrowed_range concept
template <typename ReferenceType>
inline constexpr bool std::ranges::enable_borrowed_range<podio::RelationRange<ReferenceType>> = true;

#endif // PODIO_RELATIONRANGE_H
13 changes: 13 additions & 0 deletions tests/unittests/std_interoperability.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "datamodel/ExampleHit.h"
#include "datamodel/ExampleHitCollection.h"
#include "datamodel/MutableExampleHit.h"

#include "podio/LinkCollection.h"
#include "podio/RelationRange.h"

#include <catch2/catch_test_macros.hpp>

Expand Down Expand Up @@ -1195,5 +1197,16 @@ TEST_CASE("LinkCollection and range concepts", "[links][iterator][std]") {
STATIC_REQUIRE(std::ranges::viewable_range<link_collection>);
}

TEST_CASE("RelationRange as range", "[relations][ranges][std]") {
using relation_range = podio::RelationRange<ExampleHit>;

STATIC_REQUIRE(std::ranges::contiguous_range<relation_range>);
STATIC_REQUIRE(std::ranges::sized_range<relation_range>);
STATIC_REQUIRE(std::ranges::common_range<relation_range>);
STATIC_REQUIRE(std::ranges::viewable_range<relation_range>);
STATIC_REQUIRE(std::ranges::view<relation_range>);
STATIC_REQUIRE(std::ranges::borrowed_range<relation_range>);
}

#undef DOCUMENTED_STATIC_FAILURE
#undef DOCUMENTED_FAILURE