boost-ext/di

Bug unique_ptr type plus di:unique scope turns out singleton

cantoo opened this issue · 0 comments

Expected Behavior

unique objects

Actual Behavior

singleton object

Steps to Reproduce the Problem

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

namespace di = boost::di;

class interface {
 public:
  virtual ~interface() noexcept = default;
};

class implement : public interface {};

static const auto injector = di::make_injector(
  di::bind<interface>.to<implement>().in(di::unique)
);

int main() {
  auto a1 = injector.create<std::unique_ptr<interface>>().get();
  auto a2 = injector.create<std::unique_ptr<interface>>().get();
    
  std::cout << a1 << std::endl << a2 << std::endl;
}

Specifications

  • Version: master
  • Platform: wandbox + gcc 7.1
  • Subsystem: