diff --git a/include/podio/RelationRange.h b/include/podio/RelationRange.h index 42f885f44..06fd87117 100644 --- a/include/podio/RelationRange.h +++ b/include/podio/RelationRange.h @@ -1,7 +1,7 @@ #ifndef PODIO_RELATIONRANGE_H #define PODIO_RELATIONRANGE_H -#include +#include #include namespace podio { @@ -57,4 +57,11 @@ class RelationRange { }; } // namespace podio +// Opt-in to view concept +template +inline constexpr bool std::ranges::enable_view> = true; +// Opt-in to borrowed_range concept +template +inline constexpr bool std::ranges::enable_borrowed_range> = true; + #endif // PODIO_RELATIONRANGE_H diff --git a/tests/unittests/std_interoperability.cpp b/tests/unittests/std_interoperability.cpp index 6f4acc890..591e92f9c 100644 --- a/tests/unittests/std_interoperability.cpp +++ b/tests/unittests/std_interoperability.cpp @@ -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 @@ -1195,5 +1197,16 @@ TEST_CASE("LinkCollection and range concepts", "[links][iterator][std]") { STATIC_REQUIRE(std::ranges::viewable_range); } +TEST_CASE("RelationRange as range", "[relations][ranges][std]") { + using relation_range = podio::RelationRange; + + STATIC_REQUIRE(std::ranges::contiguous_range); + STATIC_REQUIRE(std::ranges::sized_range); + STATIC_REQUIRE(std::ranges::common_range); + STATIC_REQUIRE(std::ranges::viewable_range); + STATIC_REQUIRE(std::ranges::view); + STATIC_REQUIRE(std::ranges::borrowed_range); +} + #undef DOCUMENTED_STATIC_FAILURE #undef DOCUMENTED_FAILURE