Daniel Duffy
C++ author, trainer
- Joined
- 10/4/07
- Messages
- 10,335
- Points
- 648
Concepts are the heaviest addition, and are really a paradigm shift.
Indeed, but once you get the hang of it it becomes easier.
I have lots of practical examples.
Really exciting. It's all got to do with deciding at which (meta) level to define and subsequently, use "things".
Indeed, but once you get the hang of it it becomes easier.
I have lots of practical examples.
Really exciting. It's all got to do with deciding at which (meta) level to define and subsequently, use "things".
C++:
// Interface contract specification
template<typename T>
concept IInput = requires (T x) { x.message(); };
template<typename T>
concept IOutput = requires (T x, const std::string& s) { x.print(s); };
// I/O stuff
template <typename I, typename O> requires IInput<I> && IOutput<O>
class SUD
{ // System under discussion, using composition
private:
I i; O o;
public:
SUD(const I& input, const O& output) : i(input), o(output) {}
void run()
{ o.print(i.message()); }
};
Last edited: