Chinese Yellow Pages | Classifieds | Knowledge | Tax | IME


concept ( can put some limit/restrict on the template type )

template <template-parameter-list>
concept concept-name = constraint-expression;

#include <iostream>
#include <vector>//first define a concept for print
//lets call it 'Printable'template<typename T>
concept Printable = requires(std::ostream& os, const T& msg)
    {os << msg};
};//now impose the constraint define above on print method
template <Printable T>
void print(const T& msg){
    std::cout << msg;


Here, the filtering and transformation operations are not performed until we actually iterate through the result. This lazy evaluation reduces memory usage and CPU time. The code is simpler, cleaner, and definitely smarter

coroutines ( hard to use )


Leave a Reply

Your email address will not be published. Required fields are marked *