C++ features by examples

fold More...

Collaboration diagram for Folding:

Functions

template<typename... Args>
constexpr bool folding_and (Args... args)
 
template<typename... Args>
constexpr auto folding_sum (Args... args)
 
void folding_demo ()
 

Detailed Description

fold

Function Documentation

◆ folding_and()

template<typename... Args>
constexpr bool folding_and ( Args...  args)
constexpr

Definition at line 274 of file 17.cpp.

274{ return (true && ... && args); }
Here is the caller graph for this function:

◆ folding_demo()

void folding_demo ( )

Definition at line 279 of file 17.cpp.

280{
281 static_assert(!folding_and(true, false, true));
282 static_assert(folding_sum(1.0, 2.0f, 3) == 6.0);
283}
constexpr bool folding_and(Args... args)
Definition: 17.cpp:274
constexpr auto folding_sum(Args... args)
Definition: 17.cpp:277
Here is the call graph for this function:
Here is the caller graph for this function:

◆ folding_sum()

template<typename... Args>
constexpr auto folding_sum ( Args...  args)
constexpr

Definition at line 277 of file 17.cpp.

277{ return (... + args); }
Here is the caller graph for this function: