The Gaudi Framework  master (b9786168)
Loading...
Searching...
No Matches
Gaudi::Functional::details::zip Namespace Reference

Functions

template<typename OS, typename Arg>
void printSizes (OS &out, Arg &&arg)
 Print the parameter.
 
template<typename OS, typename Arg, typename... Args>
void printSizes (OS &out, Arg &&arg, Args &&... args)
 Print the parameters.
 
template<typename A>
bool check_sizes (const A &) noexcept
 Resolve case there is only one container in the range.
 
template<typename A, typename B>
bool check_sizes (const A &a, const B &b) noexcept
 Compare sizes of two containers.
 
template<typename A, typename B, typename... C>
bool check_sizes (const A &a, const B &b, const C &... c) noexcept
 Compare sizes of 3 or more containers.
 
template<typename... Args>
decltype(auto) verifySizes (Args &... args)
 Verify the data container sizes have the same sizes.
 
template<typename... Args>
decltype(auto) range (Args &&... args)
 Zips multiple containers together to form a single range.
 
template<typename... Args>
decltype(auto) const_range (Args &&... args)
 Zips multiple containers together to form a single const range.
 

Function Documentation

◆ check_sizes() [1/3]

template<typename A>
bool Gaudi::Functional::details::zip::check_sizes ( const A & )
inlinenoexcept

Resolve case there is only one container in the range.

Definition at line 52 of file details.h.

52 {
53 return true;
54 }

◆ check_sizes() [2/3]

template<typename A, typename B>
bool Gaudi::Functional::details::zip::check_sizes ( const A & a,
const B & b )
inlinenoexcept

Compare sizes of two containers.

Definition at line 58 of file details.h.

58 {
59 return a.size() == b.size();
60 }

◆ check_sizes() [3/3]

template<typename A, typename B, typename... C>
bool Gaudi::Functional::details::zip::check_sizes ( const A & a,
const B & b,
const C &... c )
inlinenoexcept

Compare sizes of 3 or more containers.

Definition at line 64 of file details.h.

64 {
65 return ( check_sizes( a, b ) && check_sizes( b, c... ) );
66 }
bool check_sizes(const A &) noexcept
Resolve case there is only one container in the range.
Definition details.h:52

◆ const_range()

template<typename... Args>
decltype(auto) Gaudi::Functional::details::zip::const_range ( Args &&... args)
inline

Zips multiple containers together to form a single const range.

Definition at line 94 of file details.h.

94 {
95#ifndef NDEBUG
96 verifySizes( args... );
97#endif
98#if defined( GAUDI_FUNCTIONAL_USES_STD_RANGES )
99 return std::ranges::as_const_view( std::ranges::zip_view( std::forward<Args>( args )... ) );
100#else
101 return ranges::views::const_( ranges::views::zip( std::forward<Args>( args )... ) );
102#endif
103 }
decltype(auto) verifySizes(Args &... args)
Verify the data container sizes have the same sizes.
Definition details.h:70

◆ printSizes() [1/2]

template<typename OS, typename Arg>
void Gaudi::Functional::details::zip::printSizes ( OS & out,
Arg && arg )

Print the parameter.

Definition at line 38 of file details.h.

38 {
39 out << "SizeOf'" << System::typeinfoName( typeid( Arg ) ) << "'=" << std::forward<Arg>( arg ).size();
40 }
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition System.cpp:260

◆ printSizes() [2/2]

template<typename OS, typename Arg, typename... Args>
void Gaudi::Functional::details::zip::printSizes ( OS & out,
Arg && arg,
Args &&... args )

Print the parameters.

Definition at line 44 of file details.h.

44 {
45 printSizes( out, arg );
46 out << ", ";
47 printSizes( out, args... );
48 }
void printSizes(OS &out, Arg &&arg)
Print the parameter.
Definition details.h:38

◆ range()

template<typename... Args>
decltype(auto) Gaudi::Functional::details::zip::range ( Args &&... args)
inline

Zips multiple containers together to form a single range.

Definition at line 81 of file details.h.

81 {
82#ifndef NDEBUG
83 verifySizes( args... );
84#endif
85#if defined( GAUDI_FUNCTIONAL_USES_STD_RANGES )
86 return std::ranges::zip_view( std::forward<Args>( args )... );
87#else
88 return ranges::views::zip( std::forward<Args>( args )... );
89#endif
90 }

◆ verifySizes()

template<typename... Args>
decltype(auto) Gaudi::Functional::details::zip::verifySizes ( Args &... args)
inline

Verify the data container sizes have the same sizes.

Definition at line 70 of file details.h.

70 {
71 if ( !check_sizes( args... ) ) {
72 std::ostringstream mess;
73 mess << "Zipped containers have different sizes : ";
74 printSizes( mess, args... );
75 throw GaudiException( mess.str(), "Gaudi::Functional::details::zip::verifySizes", StatusCode::FAILURE );
76 }
77 }
Define general base for Gaudi exception.
constexpr static const auto FAILURE
Definition StatusCode.h:100