// // 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) // //<- #if defined(__cpp_concepts) //-> #include "boost/di/extension/injections/concepts.hpp" #include namespace di = boost::di; template concept bool Dummy() { return requires(T a) { {a.dummy()}; }; } struct DummyImpl { void dummy() {} }; auto dummy_concept = [] {}; struct example { BOOST_DI_INJECT(example, int i, auto t, (named = dummy_concept) Dummy d, (named = dummy_concept) std::unique_ptr up) { assert(42 == i); static_assert(std::is_same::value, ""); assert(87 == t); static_assert(std::is_same::value, ""); static_assert(std::is_same>::value, ""); } }; int main() { // clang-format off auto injector = di::make_injector( di::bind.to(42) , di::bind.to(87) , di::bind().named(dummy_concept).to() ); // clang-format on injector.create(); } //<- #else int main() {} #endif //->