Skip to content

DI Runtime Injector fails to compile for bind to a value #535

Open
@hanexthink

Description

@hanexthink

Expected Behavior

Should compile

Actual Behavior

/Users/hafshari/.conan/data/di/1.2.0/jenkins-clt/stable/package/964905e09401b68ee5f6b695b187d4fa9eb760c2/include/boost/di/extension/providers/runtime_provider.hpp:125:14: error: call to member function 'make' is ambiguous
return make(binding);
^~~~~~~~~~~~~~~~~~~~~~~
main.cpp:15:11: note: in instantiation of function template specialization 'boost::di::extension::detail::injector<boost::di::extension::assert_error_policy, boost::di::extension::shared_config>::install<boost::di::core::dependency<boost::di::scopes::instance, A>, 0>' requested here
injector.install(bind.to(A(1)));
^
/Users/hafshari/.conan/data/di/1.2.0/jenkins-clt/stable/package/964905e09401b68ee5f6b695b187d4fa9eb760c2/include/boost/di/extension/providers/runtime_provider.hpp:158:8: note: candidate function [with T = A, TBinding = boost::di::core::dependency<boost::di::scopes::instance, A>]
auto make(const TBinding &) -> decltype(make_impl(typename ctor_traits::type{})) {
^
/Users/hafshari/.conan/data/di/1.2.0/jenkins-clt/stable/package/964905e09401b68ee5f6b695b187d4fa9eb760c2/include/boost/di/extension/providers/runtime_provider.hpp:163:8: note: candidate function [with T = A, TBinding = boost::di::core::dependency<boost::di::scopes::instance, A>]
auto make(const TBinding &binding) -> decltype(new T{binding.object_}) {
^
1 error generated.
make: *** [main] Error 1

Steps to Reproduce the Problem

  1. You could verify the issue compiling the following source code

#include <boost/di.hpp>
#include <boost/di/extension/providers/runtime_provider.hpp>

using namespace boost::di;

struct A {
A(int) {};
virtual int now() {return 1;};
};

int main()
{
auto inj = make_injector();
extension::runtime_injector injector;
injector.install(bind.to(A(1)));
return 0;
}

Specifications

  • Version: v1.2.0
  • Platform: macOS Monterey 12.1
  • Subsystem:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions