boost-ext / di

C++14 Dependency Injection Library
https://boost-ext.github.io/di
1.16k stars 140 forks source link

Cannot declare class as final #368

Closed kanstantsin-chernik closed 5 years ago

kanstantsin-chernik commented 5 years ago

Expected Behavior

Final class is bound successfully

Actual Behavior

di.hpp(618): error C3246: 'boost::di::v1_1_0::aux::callable_base<T>': cannot inherit from 'impl1_final' as it has been declared as 'final'

Steps to Reproduce the Problem

#include "boost/di.hpp"
#include <memory>

namespace di = boost::di;

struct i1 {
  virtual ~i1() noexcept = default;
  virtual void dummy1() = 0;
};

struct impl1_final final : i1 {
  void dummy1() override {}
};
test bind_final_class_instance = [] {
  auto injector = di::make_injector(di::bind<impl1_final>().to([](){return std::make_unique<impl1_final>();}));
  auto object = injector.create<std::unique_ptr<impl1_final>>();

  expect(dynamic_cast<impl1_final *>(object.get()));
};

Specifications

kanstantsin-chernik commented 5 years ago

is_invocable doesn't work the same way as is_callable because of msvc issue. As soon as fix will be released will be able to reuse