// // 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 //-> #include namespace di = boost::di; //<- #if defined(_MSC_VER) class Type; class Number; #endif //-> template struct hello { using type = T; explicit hello(const TNumber& number) : number{number} {} TNumber number; }; template struct world { using type = T; }; int main() { auto i = 42; // clang-format off const auto injector = di::make_injector( di::bind().to() , di::bind().to(i) ); // clang-format on { const auto hw = injector.create(); static_assert(std::is_same{}, "Type != int"); assert(42 == hw.number); } { const auto hw = injector.create())>>(); static_assert(std::is_same{}, "Type != int"); assert(42 == hw->number); } }