// // Copyright (c) 2012-2020 Kris Jusiak (kris at jusiak dot net) // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include #include #include "example/polymorphism/common/config.hpp" //<- #if defined(__cpp_concepts) && !defined(_MSC_VER) //-> template concept Drawable = not boost::di::aux::is_complete::value or requires(T t, std::ostream& out) { t.draw(out); }; /*<>*/ template // requires Drawable class App { public: explicit App(const TDrawable drawable) : drawable{drawable} {} void draw(std::ostream& out) const { drawable.draw(out); } private: const TDrawable drawable; }; struct Square { void draw(std::ostream& out) const { out << "Square"; } }; struct Circle { void draw(std::ostream& out) const { out << "Circle"; } }; int main() { std::stringstream str{}; auto example = config().create(); example.draw(str); assert("Square" == str.str()); } //<- #else int main() {} #endif //->