Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/podio/utilities/StaticConcatenate.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #ifndef PODIO_UTILITIES_STATICCONCATENATE_H
0002 #define PODIO_UTILITIES_STATICCONCATENATE_H
0003 
0004 #include <algorithm>
0005 #include <array>
0006 #include <string_view>
0007 namespace podio::utils {
0008 
0009 /// Helper struct to concatenate a set of string_views into a single string_view at compile time
0010 template <const std::string_view&... strs>
0011 struct static_concatenate {
0012   static constexpr auto init_arr() {
0013     constexpr auto total_size = (strs.size() + ... + 1); // reserve space for '\0'
0014     auto arr = std::array<char, total_size>();
0015     auto it = arr.begin();
0016     ((it = std::ranges::copy(strs, it).out), ...);
0017     arr.back() = '\0';
0018     return arr;
0019   }
0020   constexpr static auto array = init_arr();
0021   constexpr static auto value = std::string_view(array.data(), array.size() - 1); // skip '\0'
0022 };
0023 
0024 /// Variable template for concatenating a set of string_views into a single string_view at compile time
0025 template <const std::string_view&... strs>
0026 inline constexpr std::string_view static_concatenate_v = static_concatenate<strs...>::value;
0027 
0028 } // namespace podio::utils
0029 #endif // PODIO_UTILITIES_STATICCONCATENATE_H