| 15 | void draw(struct Circle const &, std::ostream &); |
| 16 | |
| 17 | struct Drawable { |
| 18 | void draw(std::ostream &out) const { |
| 19 | te::call( |
| 20 | [](auto const &self, auto &out) { |
| 21 | if |
| 22 | constexpr(std::experimental::is_detected<drawable_t, decltype(self), |
| 23 | decltype(out)>{}) { |
| 24 | self.draw(out); |
| 25 | } |
| 26 | else { |
| 27 | ::draw(self, out); |
| 28 | } |
| 29 | }, |
| 30 | *this, out); |
| 31 | } |
| 32 | |
| 33 | private: |
| 34 | template <class T, class... Ts> |
| 35 | using drawable_t = decltype(std::declval<T>().draw(std::declval<Ts>()...)); |
| 36 | }; |
| 37 | |
| 38 | struct Square { |
| 39 | void draw(std::ostream &out) const { out << "Member Square"; } |