Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug unique_ptr type plus di:unique scope turns out singleton #524

Open
cantoo opened this issue Jul 21, 2021 · 0 comments
Open

Bug unique_ptr type plus di:unique scope turns out singleton #524

cantoo opened this issue Jul 21, 2021 · 0 comments

Comments

@cantoo
Copy link

cantoo commented Jul 21, 2021

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:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant