DI: C++14 Dependency Injection Library

Overview

Boost Licence Version Build Status Build Status Coveralls Github Issues Try it online


[Boost::ext].DI

Your C++14 one header only Dependency Injection library with no dependencies

Dependency Injection

https://www.youtube.com/watch?v=yVogS4NbL6U


Quick start

Download

[Boost::ext].DI requires only one file. Get the latest header here!

Include

#include <boost/di.hpp>
namespace di = boost::di;

Compile

  • GCC/Clang
    $CXX -std=c++14 -O2 -fno-exceptions -fno-rtti -Wall -Werror -pedantic-errors file.cpp
  • MSVC
    cl /std:c++14 /Ox /W3 file.cpp

Quick guide - Create object graph

class ctor {
public:
  explicit ctor(int i) : i(i) {}
  int i;
};

struct aggregate {
  double d;
};

class example {
 public:
  example(aggregate a, const ctor& c) {
    assert(87.0 == a.d);
    assert(42 == c.i);
  };
};

int main() {
  const auto injector = di::make_injector(
    di::bind<int>.to(42),
    di::bind<double>.to(87.0)
  );

  injector.create<example>();
}

Run this example on Wandbox.

Clang-3.8 GCC-6 MSVC-2015
Compilation Time 0.102s 0.118s 0.296s
Binary size (stripped) 6.2kb 6.2kb 105kb
ASM x86-64

xor eax, eax
retq
      

Quick guide - Bind interfaces

struct interface {
  virtual ~interface() noexcept = default;
  virtual int get() const = 0;
};

class implementation : public interface {
public:
  int get() const override { return 42; }
};

struct example {
  example(std::shared_ptr<interface> i) {
    assert(42 == i->get());
  }
};

int main() {
  const auto injector = di::make_injector(
    di::bind<interface>.to<implementation>()
  );

  injector.create<std::unique_ptr<example>>();
}

Run this example on Wandbox.

Clang-3.8 GCC-6 MSVC-2015
Compilation Time 0.102s 0.118s 0.296s
Binary size (stripped) 6.2kb 6.2kb 105kb
ASM x86-64 (same as `make_unique`)

push   %rbx
mov    %rdi,%rbx
mov    $0x8,%edi
callq  0x4008e0 <[email protected]>
movq   $0x400c78,(%rax)
mov    %rax,(%rbx)
mov    %rbx,%rax
pop    %rbx
retq
      

Quick guide - Bind templates

template<class ErrorPolicy = class TErrorPolicy>
class simple_updater {
public:
  void update() const {
    ErrorPolicy::on("update");
  }
};

template<class Updater = class TUpdater>
class example {
public:
  explicit example(const Updater& updater)
    : updater(updater)
  { }

  void update() {
    updater.update();
  }

private:
  const Updater& updater;
};

int main() {
  struct throw_policy {
    static void on(const std::string& str) {
      throw std::runtime_error(str);
    }
  };

  const auto injector = di::make_injector(
    di::bind<class TErrorPolicy>.to<throw_policy>(),
    di::bind<class TUpdater>.to<simple_updater>()
  );

  injector.create<example>().update();
  // Terminates with an uncaught exception because of our bound error policy
}

Run this example on Wandbox.

Clang-3.8 GCC-6 MSVC-2015
Compilation Time 0.102s 0.118s 0.296s
Binary size (stripped) 6.2kb 6.2kb 105kb
ASM x86-64

xor eax, eax
retq
      

Quick guide - Bind concepts

struct Streamable {
 template<class T>
 auto requires(T&& t) -> decltype(
   int( t.read() ),
   t.write(int)
 );
};

template<class Exchange = Streamable(class ExchangeStream)
         class Engine   = Streamable(class EngineStream)>
class example {
public:
  example(Exchange exchange, Engine engine)
    : exchange(std::move(exchange)), engine(std::move(engine))
  { }
  
private:
  Exchange exchange;
  Engine engine;
};

int main() {
  const auto injector = di::make_injector(
    di::bind<Streamable(class ExchangeStream)>.to<exchange>(),
    di::bind<Streamable(class EngineStream)>.to<engine>()
  );

  injector.create<example>();
}

Run this example on Wandbox.

Clang-3.8 GCC-6 MSVC-2015
Compilation Time 0.102s 0.118s 0.296s
Binary size (stripped) 6.2kb 6.2kb 105kb
ASM x86-64

xor eax, eax
retq
      


Documentation


Disclaimer [Boost::ext].DI is not an official Boost library.

Comments
  • Compilation errors when having more than 10 dependencies

    Compilation errors when having more than 10 dependencies

    #271

    Both of 2 solutions don't work. Here's an example:

    // ConsoleApplication2.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    
    #define __has_builtin(...) 1
    #include "di.hpp"
    
    #include <memory>
    
    namespace di = boost::di;
    
    struct C1 {
    };
    
    struct C2 {
    };
    
    struct C3 {
    };
    
    struct C4 {
    };
    
    struct C5 {
    };
    
    struct C6 {
    };
    
    struct C7 {
    };
    
    struct C8 {
    };
    
    struct C9 {
    };
    
    struct C10 {
    };
    
    struct C11 {
    };
    
    struct App {
    public:
    	App(C1& c1, C2& c2, C3& c3, C4& c4, C5& c5, C6& c6, C7& c7, C8& c8, C9& c9, C10& c10, C11& c11) {
    	}
    };
    
    int main()
    {
    	const auto injector = di::make_injector(
    		di::bind<C1>().to<C1>(),
    		di::bind<C2>().to<C2>(),
    		di::bind<C3>().to<C3>(),
    		di::bind<C4>().to<C4>(),
    		di::bind<C5>().to<C5>(),
    		di::bind<C6>().to<C6>(),
    		di::bind<C7>().to<C7>(),
    		di::bind<C8>().to<C8>(),
    		di::bind<C9>().to<C9>(),
    		di::bind<C10>().to<C10>(),
    		di::bind<C11>().to<C11>()
    	);
    	injector.create<App>();
    
        return 0;
    }
    
    

    Severity Code Description Project File Line Suppression State Error C4996 'boost::di::v1_0_2::core::injector<TConfig,boost::di::v1_0_2::core::pool<boost::di::v1_0_2::aux::type_list<>>,boost::di::v1_0_2::core::dependency<TScope,T,TExpected,boost::di::v1_0_2::no_name,void>,boost::di::v1_0_2::core::dependency<TScope,C2,C2,boost::di::v1_0_2::no_name,void>,boost::di::v1_0_2::core::dependency<TScope,C3,C3,boost::di::v1_0_2::no_name,void>,boost::di::v1_0_2::core::dependency<TScope,C4,C4,boost::di::v1_0_2::no_name,void>,boost::di::v1_0_2::core::dependency<TScope,C5,C5,boost::di::v1_0_2::no_name,void>,boost::di::v1_0_2::core::dependency<TScope,C6,C6,boost::di::v1_0_2::no_name,void>,boost::di::v1_0_2::core::dependency<TScope,C7,C7,boost::di::v1_0_2::no_name,void>,boost::di::v1_0_2::core::dependency<TScope,C8,C8,boost::di::v1_0_2::no_name,void>,boost::di::v1_0_2::core::dependency<TScope,C9,C9,boost::di::v1_0_2::no_name,void>,boost::di::v1_0_2::core::dependency<TScope,C10,C10,boost::di::v1_0_2::no_name,void>,boost::di::v1_0_2::core::dependency<TScope,C11,C11,boost::di::v1_0_2::no_name,void>>::create': creatable constraint not satisfied ConsoleApplication2 c:c:\consoleapplication2\consoleapplication2.cpp 67 Error (active) expected an expression ConsoleApplication2 c:c:\ConsoleApplication2\ConsoleApplication2.cpp 67 Warning C4506 no definition for inline function 'App *boost::di::v1_0_2::concepts::type::has_to_many_constructor_parameters::max<10>::error(boost::di::v1_0_2::_)' ConsoleApplication2 c:c:\consoleapplication2\consoleapplication2.cpp 71 Error (active) no instance of function template "boost::di::v1_0_2::make_injector" matches the argument list ConsoleApplication2 c:c:\ConsoleApplication2\ConsoleApplication2.cpp 54 Error (active) type name is not allowed ConsoleApplication2 c:c:\ConsoleApplication2\ConsoleApplication2.cpp 67

    opened by sinall 12
  • Bug: Using Factory extension for create new object allocates new shared_ptr instances for depedencies

    Bug: Using Factory extension for create new object allocates new shared_ptr instances for depedencies

    I'm using both Factory and Scoped Scope extension in my project and I've run into following problem (removing Scoped Scope does not fix this)

    When using Factory extension for creating new objects further in runtime, DI allocates new shared_ptr instances for depedencies. I am using Scoped Scope, because I need to have two distinct object trees during application run that uses the same classes but different instances. Simplified and compilable source code included. See following example:

    class interface_test
    {
    public:
    
        virtual int print_address() = 0;
    };
    
    class real_test : public interface_test
    {
    public:
    
        int print_address() final
        {
            return (int)(void*)this;
        }
    };
    
    class ifactorable
    {
    
    public:
    
        virtual int get_address() = 0;
    
    };
    
    class factorable : public ifactorable
    {
    public:
    
        factorable(std::shared_ptr<interface_test> test) : test(test)
        {
    
        }
    
        int get_address() final
        {
            return test->print_address();
        }
    
    private:
    
        std::shared_ptr<interface_test> test;
    };
    
    int main() {
        // clang-format off
        auto injector1 = di::make_injector(di::bind<interface_test>().in(scoped).to<real_test>()[boost::di::override]
            , di::bind<ifactorable>().in(scoped).to<factorable>()
            , di::bind<ifactory<ifactorable>>().to(factory<factorable>{})
        );
    
        auto injector2 = di::make_injector(di::bind<interface_test>().in(scoped).to<real_test>()[boost::di::override]
            , di::bind<ifactorable>().in(scoped).to<factorable>()
            , di::bind<ifactory<ifactorable>>().to(factory<factorable>{})
        );
        // clang-format on
    
        std::shared_ptr<ifactorable> ptr1 = injector1.create<std::shared_ptr<ifactorable>>();
        std::shared_ptr<ifactorable> ptr2 = injector1.create<std::shared_ptr<ifactorable>>();
        std::unique_ptr<ifactorable> ptr3 = injector1.create<std::unique_ptr<factorable>>();
        std::unique_ptr<ifactorable> ptr4 = injector1.create<const ifactory<ifactorable> & >().create();
        std::unique_ptr<ifactorable> ptr5 = injector1.create<const ifactory<ifactorable> & >().create();
    
        std::shared_ptr<ifactorable> ptr6 = injector2.create<std::shared_ptr<ifactorable>>();
        std::unique_ptr<ifactorable> ptr7 = injector2.create<const ifactory<ifactorable> & >().create();
    
        std::cout << "These should be equal!" << std::endl;
        std::cout << "ptr 1 = " << ptr1->get_address() << std::endl;
        std::cout << "ptr 2 = " << ptr2->get_address() << std::endl;
        std::cout << "ptr 3 = " << ptr3->get_address() << std::endl;
        std::cout << "ptr 4 = " << ptr4->get_address() << std::endl;
        std::cout << "ptr 5 = " << ptr5->get_address() << std::endl;
        std::cout << "These should be equal (but different from previous group)!" << std::endl;
        std::cout << "ptr 6 = " << ptr6->get_address() << std::endl;
        std::cout << "ptr 7 = " << ptr7->get_address() << std::endl;
    
        return 0;
    }
    

    Sample output:

    These should be equal!
    ptr 1 = 5953696
    ptr 2 = 5953696
    ptr 3 = 5953696
    ptr 4 = 5958336
    ptr 5 = 5953744
    These should be equal (but different from previous group)!
    ptr 6 = 5954720
    ptr 7 = 5977712
    
    bug 
    opened by Shelim 12
  • Error when bind a QObject inherited interface to a class that has a dependency

    Error when bind a QObject inherited interface to a class that has a dependency

    Here is the diagram of the situation : test

    Here is the error message :

    In file included from /home/blm/poc-boost-di/main.cpp:4:0:
    /home/blm/poc-boost-di/./QObject/Example.h: In function ‘void QtPoc::Example()’:
    /home/blm/poc-boost-di/./QObject/Example.h:19:37: error: ‘T boost::di::v1_0_1::core::injector<TConfig, boost::di::v1_0_1::core::pool<boost::di::v1_0_1::aux::type_list<> >, TDeps ...>::create() const [with T = QtPoc::B; typename boost::di::v1_0_1::aux::enable_if<(! boost::di::v1_0_1::core::injector<TConfig, boost::di::v1_0_1::core::pool<boost::di::v1_0_1::aux::type_list<> >, TDeps ...>::is_creatable<T, boost::di::v1_0_1::no_name, boost::di::v1_0_1::aux::integral_constant<bool, true> >::value), int>::type <anonymous> = 0; TConfig = boost::di::v1_0_1::config; TDeps = {boost::di::v1_0_1::core::dependency<boost::di::v1_0_1::scopes::singleton, QtPoc::IA, QtPoc::A, boost::di::v1_0_1::no_name, void>, boost::di::v1_0_1::core::dependency<boost::di::v1_0_1::scopes::singleton, QtPoc::IC, QtPoc::C, boost::di::v1_0_1::no_name, void>}]’ is deprecated: creatable constraint not satisfied [-Werror=deprecated-declarations]
              auto b = injector.create<B>();
                                        ^
     In file included from /home/blm/poc-boost-di/./QObject/Example.h:5:0,
                      from /home/blm/poc-boost-di/main.cpp:4:
    /home/blm/poc-boost-di/./boost/di.hpp:2417:3: note: declared here
    create
     ^
    /home/blm/poc-boost-di/./boost/di.hpp: At global scope:
    /home/blm/poc-boost-di/./boost/di.hpp:891:2: error: inline function ‘static T* boost::di::v1_0_1::concepts::abstract_type<T>::is_not_bound::error(boost::di::v1_0_1::_) [with T = QtPoc::A]’ used but never defined [-Werror]
    error(_ = "type is not bound, did you forget to add: 'di::bind<interface>.to<implementation>()'?");
    ^
    cc1plus: all warnings being treated as errors
    

    But when I remove the IC& dependency in A or remove the QObject inheritance from IA, I don't have any error. test2

    Injection code :

            auto injector = boost::di::make_injector
                    (
                            boost::di::bind<IA>().to<A>().in(boost::di::singleton),
                            boost::di::bind<IC>().to<C>().in(boost::di::singleton)
                    );
            auto b = injector.create<B>();
    
    

    How can I avoid this error ?

    opened by LempereurBenjamin 10
  • Doesn't compile with msvc 2019

    Doesn't compile with msvc 2019

    Expected Behavior

    Compiling as usual.

    Actual Behavior

    After upgrading my project from msvc 2017 to msvc 2019 boost di doesn't compile anymore. Even creating a basic example as shown below doesn't work anymore.

    Steps to Reproduce the Problem

    Use msvc 2019 and any of the language standard settings (default, c++14, c++17, c++latest)

    #include <boost/di.hpp>
    class Foo
    {	
    };
    int main(int argc, char* argv[])
    {
    	auto injector = boost::di::make_injector();
    	injector.create<Foo>();
    	return 0;
    }
    

    the error:

    boost\di.hpp(2955,18): error C2440: 'static_cast': cannot convert from 'TDefault' to 'boost::di::v1_1_0::core::dependency__<dependency_t> &' boost\di.hpp(2955,18): error C2440: with boost\di.hpp(2955,18): error C2440: [ boost\di.hpp(2955,18): error C2440: TDefault=boost::di::v1_1_0::core::dependencyboost::di::v1_1_0::scopes::deduce,Foo,Foo,boost::di::v1_1_0::no_name,void,boost::di::v1_1_0::core::none boost\di.hpp(2955,18): error C2440: ] boost\di.hpp(2955,18): message : static_cast and safe_cast to reference can only be used for valid initializations or for lvalue casts between related classes boost\di.hpp(2879): message : see reference to function template instantiation 'auto boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>>::create_successful_impl__<TIsRoot,T,boost::di::v1_1_0::no_name>(void) const' being compiled boost\di.hpp(2879): message : with boost\di.hpp(2879): message : [ boost\di.hpp(2879): message : TConfig=boost::di::v1_1_0::config, boost\di.hpp(2879): message : TIsRoot=boost::di::v1_1_0::aux::true_type, boost\di.hpp(2879): message : T=Foo boost\di.hpp(2879): message : ] boost\di.hpp(2772): message : see reference to function template instantiation 'auto boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>>::create_successful_implboost::di::v1_1_0::aux::true_type,T(const boost::di::v1_1_0::aux::type &) const' being compiled boost\di.hpp(2772): message : with boost\di.hpp(2772): message : [ boost\di.hpp(2772): message : TConfig=boost::di::v1_1_0::config, boost\di.hpp(2772): message : T=Foo boost\di.hpp(2772): message : ] main.cpp(10): message : see reference to function template instantiation 'T boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>>::create<Foo,0>(void) const' being compiled main.cpp(10): message : with main.cpp(10): message : [ main.cpp(10): message : T=Foo, main.cpp(10): message : TConfig=boost::di::v1_1_0::config main.cpp(10): message : ] main.cpp(10): message : see reference to function template instantiation 'T boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>>::create<Foo,0>(void) const' being compiled main.cpp(10): message : with main.cpp(10): message : [ main.cpp(10): message : T=Foo, main.cpp(10): message : TConfig=boost::di::v1_1_0::config main.cpp(10): message : ] boost\di.hpp(2955,107): error C2027: use of undefined type 'boost::di::v1_1_0::core::successful::provider<ctor_t,boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>>>' boost\di.hpp(2955,107): error C2027: with boost\di.hpp(2955,107): error C2027: [ boost\di.hpp(2955,107): error C2027: TConfig=boost::di::v1_1_0::config boost\di.hpp(2955,107): error C2027: ] boost\di.hpp(2953): message : see declaration of 'boost::di::v1_1_0::core::successful::provider<ctor_t,boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>>>' boost\di.hpp(2953): message : with boost\di.hpp(2953): message : [ boost\di.hpp(2953): message : TConfig=boost::di::v1_1_0::config boost\di.hpp(2953): message : ] boost\di.hpp(2958,9): error C2440: 'static_cast': cannot convert from 'TDefault' to 'boost::di::v1_1_0::core::dependency__<dependency_t> &' boost\di.hpp(2958,9): error C2440: with boost\di.hpp(2958,9): error C2440: [ boost\di.hpp(2958,9): error C2440: TDefault=boost::di::v1_1_0::core::dependencyboost::di::v1_1_0::scopes::deduce,Foo,Foo,boost::di::v1_1_0::no_name,void,boost::di::v1_1_0::core::none boost\di.hpp(2958,9): error C2440: ] boost\di.hpp(2958,9): message : static_cast and safe_cast to reference can only be used for valid initializations or for lvalue casts between related classes boost\di.hpp(2958,13): error C2027: use of undefined type 'boost::di::v1_1_0::core::successful::provider<ctor_t,boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>>>' boost\di.hpp(2958,13): error C2027: with boost\di.hpp(2958,13): error C2027: [ boost\di.hpp(2958,13): error C2027: TConfig=boost::di::v1_1_0::config boost\di.hpp(2958,13): error C2027: ] boost\di.hpp(2953): message : see declaration of 'boost::di::v1_1_0::core::successful::provider<ctor_t,boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>>>' boost\di.hpp(2953): message : with boost\di.hpp(2953): message : [ boost\di.hpp(2953): message : TConfig=boost::di::v1_1_0::config boost\di.hpp(2953): message : ] boost\di.hpp(2948): error C2641: cannot deduce template arguments for 'boost::di::v1_1_0::core::successful::wrapper' boost\di.hpp(2948,1): error C2783: 'boost::di::v1_1_0::core::successful::wrapper<T,TWrapper> boost::di::v1_1_0::core::successful::wrapper(void)': could not deduce template argument for 'T' boost\di.hpp(2455): message : see declaration of 'boost::di::v1_1_0::core::successful::wrapper' boost\di.hpp(2948,1): error C2783: 'boost::di::v1_1_0::core::successful::wrapper<T,TWrapper> boost::di::v1_1_0::core::successful::wrapper(void)': could not deduce template argument for 'TWrapper' boost\di.hpp(2455): message : see declaration of 'boost::di::v1_1_0::core::successful::wrapper' boost\di.hpp(2957,2): error C2512: 'boost::di::v1_1_0::core::successful::wrapper': no appropriate default constructor available boost\di.hpp(2957,2): message : The target type has no constructors boost\di.hpp(2773,12): error C2440: 'type cast': cannot convert from 'void' to 'T &&' boost\di.hpp(2773,12): error C2440: with boost\di.hpp(2773,12): error C2440: [ boost\di.hpp(2773,12): error C2440: T=Foo boost\di.hpp(2773,12): error C2440: ] boost\di.hpp(2773,12): message : Expressions of type void cannot be converted to other types

    Specifications

    • Version: 1.1 or latest git version
    • Platform: Windows
    • Subsystem: msvc 2019
    bug 
    opened by Manulan27 9
  • Broken under VS2015 Update 3

    Broken under VS2015 Update 3

    The following code doesn't compile under VS2015 Update 3:

    struct A {
        virtual void x() = 0;
    }
    
    struct B : public A {
        virtual void x() override {}
    }
    
    auto injector = di::make_injector(
        di::bind<A>().to<B>()
    );
    
    injector.create<A>();
    

    Note that without the method x, it works. It also works when calling injector.create<B>() instead.

    The error is something like "no matching overload function found".

    opened by alongubkin 9
  • boost::di::extension::shared_config doesn't work correctly with MSVC release build

    boost::di::extension::shared_config doesn't work correctly with MSVC release build

    Hi, first off: Thank you for this amazing library!

    Unfortunately, I found a bug with boost::di::extension::shared_config when using the MSVC compiler in release mode.

    Take this minimal example:

    #include <iostream>
    
    #include "boost/di.hpp"
    #include "boost/di/extension/scopes/shared.hpp"
    
    class Bar {
    public:
        int getI() const { return i; }
    
    private:
        int i = 2;
    };
    
    class Foo {
    public:
        Foo(std::shared_ptr<Bar> bar) : bar(std::move(bar)) {}
        std::shared_ptr<Bar> getBar() {  return bar; }
    
    private:
        std::shared_ptr<Bar> bar;
    };
    
    class IBaz {
    public:
        virtual ~IBaz() = default;
    };
    
    class Baz : public IBaz {
    };
    
    int main() {
        auto injector = boost::di::make_injector<boost::di::extension::shared_config>();
    
        auto baz = injector.create<std::shared_ptr<Baz>>();
        auto foo = injector.create<std::unique_ptr<Foo>>();
    
        std::cout << std::to_string(foo->getBar()->getI()) << std::endl;
    }
    
    

    This code runs fine with GCC in debug and release mode, as well as with MSVC in Debug mode and this program will print 2. A release build created with the MSVC compiler will print a random number because of some lifetime problem.

    Some things I observed:

    • Changing class Baz : public IBaz to class Baz (not implementing the interface) will cause the expected behavior
    • Changing boost::di::make_injector<boost::di::extension::shared_config> to boost::di::make_injector will also cause the expected behavior

    Expected Behavior

    Output: 2

    Actual Behavior

    Undefined Behavior

    Specifications

    • Version: v1.2.0 as well as the current master
    • Platform: Windows with MSVC 19.28.29336.0
    opened by JulZimmermann 7
  • Can't compile with gcc 10

    Can't compile with gcc 10

    Expected Behavior

    Expected to compile.

    Actual Behavior

    Can't compile the quick guide example (or any other application using boost::di) with the gcc 10 compiler

    Error Message:

    <source>: In member function 'boost::di::v1_1_0::core::binder::resolve_template_t<boost::di::v1_1_0::core::injector<TConfig, TPolicies, TDeps>, boost::di::v1_1_0::aux::identity<T<> > > boost::di::v1_1_0::core::injector<TConfig, TPolicies, TDeps>::create() const':
    
    <source>:2575:77: error: 'boost::di::v1_1_0::core::binder::resolve_template_t<boost::di::v1_1_0::core::injector<TConfig, TPolicies, TDeps>, boost::di::v1_1_0::aux::identity<T<> > > boost::di::v1_1_0::core::injector<TConfig, TPolicies, TDeps>::create() const' is deprecated: creatable constraint not satisfied [-Werror=deprecated-declarations]
    
     2575 |     return __BOOST_DI_TYPE_WKND(type) create_impl<aux::true_type>(aux::type<type>{});
    
          |                                                                             ^~~~
    
    <source>:2571:3: note: declared here
    
     2571 |   create()
    
          |   ^~~~~~
    
    <source>: In member function 'boost::di::v1_1_0::core::binder::resolve_template_t<boost::di::v1_1_0::core::injector<TConfig, boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<> >, TDeps ...>, boost::di::v1_1_0::aux::identity<T<> > > boost::di::v1_1_0::core::injector<TConfig, boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<> >, TDeps ...>::create() const':
    
    <source>:2803:77: error: 'boost::di::v1_1_0::core::binder::resolve_template_t<boost::di::v1_1_0::core::injector<TConfig, boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<> >, TDeps ...>, boost::di::v1_1_0::aux::identity<T<> > > boost::di::v1_1_0::core::injector<TConfig, boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<> >, TDeps ...>::create() const' is deprecated: creatable constraint not satisfied [-Werror=deprecated-declarations]
    
     2803 |     return __BOOST_DI_TYPE_WKND(type) create_impl<aux::true_type>(aux::type<type>{});
    
          |                                                                             ^~~~
    
    <source>:2799:3: note: declared here
    
     2799 |   create()
    
          |   ^~~~~~
    
    cc1plus: some warnings being treated as errors
    
    Compiler returned: 1
    

    Steps to Reproduce the Problem

    1. Use gcc 10 compiler
    2. compile the example

    Here is a Compiler Explorer link showing the problem: https://godbolt.org/z/xvHTfd By switching the compiler to gcc 9.3 the code compiles just fine.

    Specifications

    • Version: Current Version from "Get the latest header here"
    • Platform: Linux
    opened by JulZimmermann 6
  • Adding default Destructor breaks Compilation

    Adding default Destructor breaks Compilation

    Hello, thank you for your work on this promising and interesting library. As I have already mentioned in another thread I am evaluating and exploring this library a little bit.

    For the following code uncommenting the default destructor for vulkan::Instance breaks compilation with the error attached at the bottom of this message.

    #include <DI/di.hpp>
    namespace di = boost::di;
    
    #include <iostream>
    #include <tuple>
    
    #pragma once
    
    #define GLFW_INCLUDE_VULKAN
    #include <GLFW/glfw3.h>
    #include <vulkan/vulkan.hpp>
    
    #include <iostream>
    #include <optional>
    #include <vector>
    
    
    struct AppName { char const* name; };
    
    namespace glfw {
    	class Instance {
    	public:
    		Instance();
    
    	private:
    		std::shared_ptr<nullptr_t> _deleter;
    	};
    
    	class Window {
    	public:
    		struct Height { int h; };
    		struct Width { int w; };
    
    		Window(Instance const& instance, AppName const& appName, Height h, Width w);
    		Window(GLFWwindow* window);
    
    		operator GLFWwindow& ();
    		operator GLFWwindow const&() const;
    		GLFWwindow& operator* ();
    		GLFWwindow const& operator*() const;
    
    	private:
    		std::shared_ptr<GLFWwindow> _window;
    	};
    }
    
    namespace vulkan {
    	struct DebuggingLayersFlag {
    		const bool enable;
    	};
    
    	template <typename Type>
    	using Handle = vk::UniqueHandle<Type, vk::DispatchLoaderStatic>;
    
    	class ValidationLayers {
    	public:
    		using NamesList = std::vector<char const*> const;
    		ValidationLayers(DebuggingLayersFlag const& enableDebuggingLayers);
    
    		NamesList getUnsupportedLayers(NamesList& requestedLayers) const;
    
    		NamesList _names;
    
    	private:
    		static NamesList constructNames(const bool enable);
    	};
    
    	class Extensions {
    	public:
    		using NamesList = std::vector<char const*> const;
    
    		Extensions
    			( DebuggingLayersFlag const& printSupportedExtensions
    			, ValidationLayers const& layers);
    
    		NamesList _names;
    
    	private:
    		static NamesList constructNames(ValidationLayers::NamesList& layerNames);
    	};
    
    	class Instance {
    	public:
    		Instance
    			( AppName const& appName
    			, ValidationLayers const& layers
    			, Extensions const& extensions
    			);
    		~Instance() = default;
    
    		operator vk::Instance& ();
    		operator vk::Instance const& () const;
    
    		vk::Instance& operator*();
    		vk::Instance const& operator*() const;
    		vk::Instance* operator->();
    		vk::Instance const*  operator->() const;
    
    	private:
    		Handle<vk::Instance> _instance;
    	};
    
    	class IDebugMessenger {
    	public:
    		virtual void callback
    			( vk::DebugUtilsMessageSeverityFlagsEXT severity
    			, vk::DebugUtilsMessageTypeFlagsEXT type
    			, vk::DebugUtilsMessengerCallbackDataEXT const* data
    			) = 0;
    	};
    
    	template <bool enableDebugging>
    	class DebugMessenger;
    
    	template <>
    	class DebugMessenger<true> : public IDebugMessenger {
    	public:
    		DebugMessenger(Instance const& instance);
    
    		void callback
    			( vk::DebugUtilsMessageSeverityFlagsEXT severity
    			, vk::DebugUtilsMessageTypeFlagsEXT type
    			, vk::DebugUtilsMessengerCallbackDataEXT const* data
    			) override;
    
    	private:
    		std::shared_ptr<nullptr_t> _resource;
    	};
    
    	template <>
    	class DebugMessenger<false> : public IDebugMessenger {
    	public:
    		DebugMessenger();
    
    		void callback
    			( vk::DebugUtilsMessageSeverityFlagsEXT severity
    			, vk::DebugUtilsMessageTypeFlagsEXT type
    			, vk::DebugUtilsMessengerCallbackDataEXT const* data
    			) override;
    	};
    
    	class Surface {
    	public:
    		Surface(Instance const& instance, glfw::Window& window);
    
    	private:
    		std::shared_ptr<vk::SurfaceKHR> _surface;
    	};
    
    	class PhysicalDevice {
    	public:
    		PhysicalDevice(Instance const& instance);
    
    		//operator vk::PhysicalDevice& ();
    		//operator vk::PhysicalDevice const& () const;
    
    		//vk::PhysicalDevice& operator*();
    		//vk::PhysicalDevice const& operator*() const;
    		vk::PhysicalDevice* operator->();
    		vk::PhysicalDevice const*  operator->() const;
    
    	private:
    		vk::PhysicalDevice _device;
    
    		static bool suitable(vk::PhysicalDevice const& device);
    	};
    
    	class QueueFamilyIndices {
    	public:
    		QueueFamilyIndices(PhysicalDevice const& device);
    
    	private:
    		std::size_t graphicsFamily;
    	};
    
    	//struct SwapchainDetails {
    	//	vk::SwapchainKHR swapchain;
    	//	std::vector<vk::Image> images;
    	//	std::vector<vk::ImageView> views;
    	//	vk::Format format;
    	//	vk::Extent2D extent;
    	//};
    
    	//struct GraphicsState {
    	//	vulkan::Instance instance;
    	//	std::optional<vk::DebugUtilsMessengerEXT> messenger;
    	//	vk::SurfaceKHR surface;
    	//	vk::PhysicalDevice phDevice;
    	//	vk::Device device;
    	//	vk::Queue graphicsQueue;
    	//	vk::Queue presentQueue;
    	//	SwapchainDetails swapchainDetails;
    	//	vk::RenderPass renderPass;
    	//	vk::PipelineLayout pipelineLayout;
    	//	vk::Pipeline pipeline;
    	//};
    
    	//auto initVulkan
    	//(uint32_t surfaceWidth, uint32_t surfaceHeight, GLFWwindow* window)
    	//	-> GraphicsState;
    
    }
    
    void showWindow();
    
    constexpr auto EnableDebugging =
    #ifndef NDEBUG
    	true;
    #else
    	false;
    #endif
    
    //struct Application {
    //	glfw::Instance glfwInstance;
    //	vulkan::Instance vulkanInstance;
    //	std::unique_ptr<vulkan::IDebugMessenger> debugMessenger;
    //	vulkan::Surface surface;
    //};
    using Application = std::tuple
    	< glfw::Instance
    	, vulkan::Instance
    	, std::unique_ptr<vulkan::IDebugMessenger>
    	, vulkan::Surface
    	, vulkan::QueueFamilyIndices
    	>;
    
    int main(int, char**)
    {
    	auto app = di::make_injector
    		( di::bind<>.to(AppName{ "ndrtest" })
    		, di::bind<>.to(vulkan::DebuggingLayersFlag{ EnableDebugging })
    		, di::bind<vulkan::IDebugMessenger>.to<vulkan::DebugMessenger<EnableDebugging>>()
    		, di::bind<>.to(glfw::Window::Height{ 600 })
    		, di::bind<>.to(glfw::Window::Width{ 800 })
    		) 
    		.create<Application>();
    
    	std::cout << std::endl;
    	return 0;
    }
    
    >------ Build started: Project: CMakeLists, Configuration: Debug ------
      [1/5] C:\PROGRA~2\MICROS~2\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\HostX64\x64\cl.exe  /nologo /TP  -I..\..\viz\include -IC:\Users\kostja\.conan\data\glfw\3.2.1\bincrafters\stable\package\8cf01e2f50fcd6b63525e70584df0326550364e1\include -IC:\VulkanSDK\1.1.101.0\Include /DWIN32 /D_WINDOWS /W3 /GR /EHsc  /MDd /Zi /Ob0 /Od /RTC1   -std:c++17 /showIncludes /Foviz\CMakeFiles\viz.dir\src\glfw.cpp.obj /Fdviz\CMakeFiles\viz.dir\viz.pdb /FS -c ..\..\viz\src\glfw.cpp
      [2/5] C:\PROGRA~2\MICROS~2\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\HostX64\x64\cl.exe  /nologo /TP  -I..\..\viz\include -IC:\Users\kostja\.conan\data\glfw\3.2.1\bincrafters\stable\package\8cf01e2f50fcd6b63525e70584df0326550364e1\include -IC:\VulkanSDK\1.1.101.0\Include /DWIN32 /D_WINDOWS /W3 /GR /EHsc  /MDd /Zi /Ob0 /Od /RTC1   -std:c++17 /showIncludes /Foviz\CMakeFiles\viz.dir\src\vulkan.cpp.obj /Fdviz\CMakeFiles\viz.dir\viz.pdb /FS -c ..\..\viz\src\vulkan.cpp
      [3/5] cmd.exe /C "cd . && C:\PROGRA~2\MICROS~2\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\link.exe /lib /nologo /machine:x64 /out:lib\viz.lib viz\CMakeFiles\viz.dir\src\glfw.cpp.obj viz\CMakeFiles\viz.dir\src\vulkan.cpp.obj  && cd ."
      [4/5] C:\PROGRA~2\MICROS~2\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\HostX64\x64\cl.exe  /nologo /TP  -I..\..\ndr\include -I..\..\viz\include -I..\..\extern\DI\include -IC:\Users\kostja\.conan\data\glfw\3.2.1\bincrafters\stable\package\8cf01e2f50fcd6b63525e70584df0326550364e1\include -IC:\VulkanSDK\1.1.101.0\Include /DWIN32 /D_WINDOWS /W3 /GR /EHsc  /MDd /Zi /Ob0 /Od /RTC1   -std:c++17 /showIncludes /FoCMakeFiles\ndrtest.dir\src\main.cpp.obj /FdCMakeFiles\ndrtest.dir\ /FS -c ..\..\src\main.cpp
      FAILED: CMakeFiles/ndrtest.dir/src/main.cpp.obj 
      C:\PROGRA~2\MICROS~2\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\HostX64\x64\cl.exe  /nologo /TP  -I..\..\ndr\include -I..\..\viz\include -I..\..\extern\DI\include -IC:\Users\kostja\.conan\data\glfw\3.2.1\bincrafters\stable\package\8cf01e2f50fcd6b63525e70584df0326550364e1\include -IC:\VulkanSDK\1.1.101.0\Include /DWIN32 /D_WINDOWS /W3 /GR /EHsc  /MDd /Zi /Ob0 /Od /RTC1   -std:c++17 /showIncludes /FoCMakeFiles\ndrtest.dir\src\main.cpp.obj /FdCMakeFiles\ndrtest.dir\ /FS -c ..\..\src\main.cpp
    C:\src\main.cpp(45): warning C4996: 'boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>,dependency,dependency,boost::di::v1_1_0::core::dependency<TScope,TExpected,T,TName,TPriority,TCtor>,dependency,dependency>::create': creatable constraint not satisfied
              with
              [
                  TConfig=boost::di::v1_1_0::config,
                  TScope=boost::di::v1_1_0::scopes::deduce,
                  TExpected=vulkan::IDebugMessenger,
                  T=vulkan::DebugMessenger<true>,
                  TName=boost::di::v1_1_0::no_name,
                  TPriority=void,
                  TCtor=boost::di::v1_1_0::core::none
              ]
      C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI/di.hpp(2780): note: see declaration of 'boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>,dependency,dependency,boost::di::v1_1_0::core::dependency<TScope,TExpected,T,TName,TPriority,TCtor>,dependency,dependency>::create'
              with
              [
                  TConfig=boost::di::v1_1_0::config,
                  TScope=boost::di::v1_1_0::scopes::deduce,
                  TExpected=vulkan::IDebugMessenger,
                  T=vulkan::DebugMessenger<true>,
                  TName=boost::di::v1_1_0::no_name,
                  TPriority=void,
                  TCtor=boost::di::v1_1_0::core::none
              ]
    C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI\di.hpp(1924): error C2440: 'initializing': cannot convert from 'initializer list' to 'wrapper'
      C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI/di.hpp(1924): note: Invalid aggregate initialization
      C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI/di.hpp(1152): note: see reference to function template instantiation 'auto boost::di::v1_1_0::scopes::unique::scope<TExpected,TGiven>::create<T,TName,TProvider>(const TProvider &) const' being compiled
              with
              [
                  TExpected=vulkan::Instance,
                  TGiven=vulkan::Instance,
                  T=vulkan::Instance,
                  TName=boost::di::v1_1_0::no_name,
                  TProvider=provider_t
              ]
      C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI/di.hpp(2937): note: see reference to function template instantiation 'auto boost::di::v1_1_0::scopes::deduce::scope<TExpected,TGiven>::create<T,TName,provider_t>(const TProvider &)' being compiled
              with
              [
                  TExpected=vulkan::Instance,
                  TGiven=vulkan::Instance,
                  T=vulkan::Instance,
                  TName=boost::di::v1_1_0::no_name,
                  TProvider=provider_t
              ]
      C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI/di.hpp(2847): note: see reference to function template instantiation 'auto boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>,dependency,dependency,boost::di::v1_1_0::core::dependency<TScope,TExpected,T,TName,TPriority,TCtor>,dependency,dependency>::create_impl__<TIsRoot,vulkan::Instance,boost::di::v1_1_0::no_name>(void) const' being compiled
              with
              [
                  TConfig=boost::di::v1_1_0::config,
                  TScope=boost::di::v1_1_0::scopes::deduce,
                  TExpected=vulkan::IDebugMessenger,
                  T=vulkan::DebugMessenger<true>,
                  TName=boost::di::v1_1_0::no_name,
                  TPriority=void,
                  TCtor=boost::di::v1_1_0::core::none,
                  TIsRoot=boost::di::v1_1_0::aux::false_type
              ]
      C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI/di.hpp(2413): note: see reference to function template instantiation 'auto boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>,dependency,dependency,boost::di::v1_1_0::core::dependency<TScope,TExpected,T,TName,TPriority,TCtor>,dependency,dependency>::create_impl<boost::di::v1_1_0::aux::false_type,vulkan::Instance>(const boost::di::v1_1_0::aux::type<vulkan::Instance> &) const' being compiled
              with
              [
                  TConfig=boost::di::v1_1_0::config,
                  TScope=boost::di::v1_1_0::scopes::deduce,
                  TExpected=vulkan::IDebugMessenger,
                  T=vulkan::DebugMessenger<true>,
                  TName=boost::di::v1_1_0::no_name,
                  TPriority=void,
                  TCtor=boost::di::v1_1_0::core::none
              ]
      C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI/di.hpp(1923): note: see reference to function template instantiation 'auto boost::di::v1_1_0::core::provider<ctor_t,TName,boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>,dependency,dependency,boost::di::v1_1_0::core::dependency<TScope,TExpected,T,TName,TPriority,TCtor>,dependency,dependency>>::get<memory>(const TMemory &) const' being compiled
              with
              [
                  TName=boost::di::v1_1_0::no_name,
                  TConfig=boost::di::v1_1_0::config,
                  TScope=boost::di::v1_1_0::scopes::deduce,
                  TExpected=vulkan::IDebugMessenger,
                  T=vulkan::DebugMessenger<true>,
                  TPriority=void,
                  TCtor=boost::di::v1_1_0::core::none,
                  TMemory=memory
              ]
      C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI/di.hpp(1152): note: see reference to function template instantiation 'auto boost::di::v1_1_0::scopes::unique::scope<TExpected,TGiven>::create<T,TName,TProvider>(const TProvider &) const' being compiled
              with
              [
                  TExpected=std::tuple<glfw::Instance,vulkan::Instance,std::unique_ptr<vulkan::IDebugMessenger,std::default_delete<vulkan::IDebugMessenger>>,vulkan::Surface,vulkan::QueueFamilyIndices>,
                  TGiven=std::tuple<glfw::Instance,vulkan::Instance,std::unique_ptr<vulkan::IDebugMessenger,std::default_delete<vulkan::IDebugMessenger>>,vulkan::Surface,vulkan::QueueFamilyIndices>,
                  T=Application,
                  TName=boost::di::v1_1_0::no_name,
                  TProvider=provider_t
              ]
      C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI/di.hpp(2937): note: see reference to function template instantiation 'auto boost::di::v1_1_0::scopes::deduce::scope<TExpected,TGiven>::create<T,TName,provider_t>(const TProvider &)' being compiled
              with
              [
                  TExpected=std::tuple<glfw::Instance,vulkan::Instance,std::unique_ptr<vulkan::IDebugMessenger,std::default_delete<vulkan::IDebugMessenger>>,vulkan::Surface,vulkan::QueueFamilyIndices>,
                  TGiven=std::tuple<glfw::Instance,vulkan::Instance,std::unique_ptr<vulkan::IDebugMessenger,std::default_delete<vulkan::IDebugMessenger>>,vulkan::Surface,vulkan::QueueFamilyIndices>,
                  T=Application,
                  TName=boost::di::v1_1_0::no_name,
                  TProvider=provider_t
              ]
      C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI/di.hpp(2847): note: see reference to function template instantiation 'auto boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>,dependency,dependency,boost::di::v1_1_0::core::dependency<TScope,TExpected,T,TName,TPriority,TCtor>,dependency,dependency>::create_impl__<TIsRoot,std::tuple<glfw::Instance,vulkan::Instance,std::unique_ptr<vulkan::IDebugMessenger,std::default_delete<_Ty>>,vulkan::Surface,vulkan::QueueFamilyIndices>,boost::di::v1_1_0::no_name>(void) const' being compiled
              with
              [
                  TConfig=boost::di::v1_1_0::config,
                  TScope=boost::di::v1_1_0::scopes::deduce,
                  TExpected=vulkan::IDebugMessenger,
                  T=vulkan::DebugMessenger<true>,
                  TName=boost::di::v1_1_0::no_name,
                  TPriority=void,
                  TCtor=boost::di::v1_1_0::core::none,
                  TIsRoot=boost::di::v1_1_0::aux::true_type,
                  _Ty=vulkan::IDebugMessenger
              ]
      C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI/di.hpp(2782): note: see reference to function template instantiation 'auto boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>,dependency,dependency,boost::di::v1_1_0::core::dependency<TScope,TExpected,T,TName,TPriority,TCtor>,dependency,dependency>::create_impl<boost::di::v1_1_0::aux::true_type,std::tuple<glfw::Instance,vulkan::Instance,std::unique_ptr<vulkan::IDebugMessenger,std::default_delete<_Ty>>,vulkan::Surface,vulkan::QueueFamilyIndices>>(const boost::di::v1_1_0::aux::type<std::tuple<glfw::Instance,vulkan::Instance,std::unique_ptr<_Ty,std::default_delete<_Ty>>,vulkan::Surface,vulkan::QueueFamilyIndices>> &) const' being compiled
              with
              [
                  TConfig=boost::di::v1_1_0::config,
                  TScope=boost::di::v1_1_0::scopes::deduce,
                  TExpected=vulkan::IDebugMessenger,
                  T=vulkan::DebugMessenger<true>,
                  TName=boost::di::v1_1_0::no_name,
                  TPriority=void,
                  TCtor=boost::di::v1_1_0::core::none,
                  _Ty=vulkan::IDebugMessenger
              ]
      ..\..\src\main.cpp(45): note: see reference to function template instantiation 'T boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>,dependency,dependency,boost::di::v1_1_0::core::dependency<TScope,TExpected,vulkan::DebugMessenger<true>,TName,TPriority,TCtor>,dependency,dependency>::create<Application,0>(void) const' being compiled
              with
              [
                  T=Application,
                  TConfig=boost::di::v1_1_0::config,
                  TScope=boost::di::v1_1_0::scopes::deduce,
                  TExpected=vulkan::IDebugMessenger,
                  TName=boost::di::v1_1_0::no_name,
                  TPriority=void,
                  TCtor=boost::di::v1_1_0::core::none
              ]
      ..\..\src\main.cpp(45): note: see reference to function template instantiation 'T boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>,dependency,dependency,boost::di::v1_1_0::core::dependency<TScope,TExpected,vulkan::DebugMessenger<true>,TName,TPriority,TCtor>,dependency,dependency>::create<Application,0>(void) const' being compiled
              with
              [
                  T=Application,
                  TConfig=boost::di::v1_1_0::config,
                  TScope=boost::di::v1_1_0::scopes::deduce,
                  TExpected=vulkan::IDebugMessenger,
                  TName=boost::di::v1_1_0::no_name,
                  TPriority=void,
                  TCtor=boost::di::v1_1_0::core::none
              ]
    C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI\di.hpp(2464): error C2182: 'wrapper_': illegal use of type 'void'
      C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI/di.hpp(2937): note: see reference to class template instantiation 'boost::di::v1_1_0::core::wrapper_impl<T,wrapper_t,int>' being compiled
              with
              [
                  T=vulkan::Instance
              ]
    C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI\di.hpp(2945): error C2440: 'initializing': cannot convert from 'initializer list' to 'boost::di::v1_1_0::core::wrapper_impl<T,wrapper_t,int>'
              with
              [
                  T=vulkan::Instance
              ]
      C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI/di.hpp(2937): note: Invalid aggregate initialization
    C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI\di.hpp(2414): error C2672: 'boost::di::v1_1_0::core::provider<ctor_t,TName,boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>,dependency,dependency,boost::di::v1_1_0::core::dependency<TScope,TExpected,T,TName,TPriority,TCtor>,dependency,dependency>>::get_impl': no matching overloaded function found
              with
              [
                  TName=boost::di::v1_1_0::no_name,
                  TConfig=boost::di::v1_1_0::config,
                  TScope=boost::di::v1_1_0::scopes::deduce,
                  TExpected=vulkan::IDebugMessenger,
                  T=vulkan::DebugMessenger<true>,
                  TPriority=void,
                  TCtor=boost::di::v1_1_0::core::none
              ]
    C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI\di.hpp(2413): error C2783: 'auto boost::di::v1_1_0::core::provider<ctor_t,TName,boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>,dependency,dependency,boost::di::v1_1_0::core::dependency<TScope,TExpected,T,TName,TPriority,TCtor>,dependency,dependency>>::get_impl(const TMemory &,TArgs &&...) const': could not deduce template argument for '__formal'
              with
              [
                  TName=boost::di::v1_1_0::no_name,
                  TConfig=boost::di::v1_1_0::config,
                  TScope=boost::di::v1_1_0::scopes::deduce,
                  TExpected=vulkan::IDebugMessenger,
                  T=vulkan::DebugMessenger<true>,
                  TPriority=void,
                  TCtor=boost::di::v1_1_0::core::none
              ]
      C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI/di.hpp(2417): note: see declaration of 'boost::di::v1_1_0::core::provider<ctor_t,TName,boost::di::v1_1_0::core::injector<TConfig,boost::di::v1_1_0::core::pool<boost::di::v1_1_0::aux::type_list<>>,dependency,dependency,boost::di::v1_1_0::core::dependency<TScope,TExpected,T,TName,TPriority,TCtor>,dependency,dependency>>::get_impl'
              with
              [
                  TName=boost::di::v1_1_0::no_name,
                  TConfig=boost::di::v1_1_0::config,
                  TScope=boost::di::v1_1_0::scopes::deduce,
                  TExpected=vulkan::IDebugMessenger,
                  T=vulkan::DebugMessenger<true>,
                  TPriority=void,
                  TCtor=boost::di::v1_1_0::core::none
              ]
    C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI\di.hpp(1356): error C2182: '<Unknown>': illegal use of type 'void'
      C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI/di.hpp(1924): note: see reference to class template instantiation 'boost::di::v1_1_0::wrappers::unique<boost::di::v1_1_0::scopes::unique,void>' being compiled
    C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI\di.hpp(1357): error C2182: 'object': illegal use of type 'void'
    C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI\di.hpp(2945): error C2440: 'initializing': cannot convert from 'initializer list' to 'boost::di::v1_1_0::core::wrapper_impl<T,wrapper_t,int>'
              with
              [
                  T=Application
              ]
      C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI/di.hpp(2937): note: Invalid aggregate initialization
    C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI\di.hpp(2782): error C2440: 'type cast': cannot convert from 'void' to 'T &&'
              with
              [
                  T=Application
              ]
      C:\Users\kostja\Dev\Algorithms\NDR\extern\DI\include\DI/di.hpp(2782): note: Expressions of type void cannot be converted to other types
      ninja: build stopped: subcommand failed.
    
    Build failed.
    

    I used version 1.1.0

    opened by heilkn 6
  • Usage Question: Why is the API not like make_unique<type> ?

    Usage Question: Why is the API not like make_unique ?

    Expected Behavior

    The API to be similar like std::make_unique and friends:

       auto injector = di::make_injector(
            // the to be injected parameters but without defined ordering
        );
       auto q = di::make_injected<QInterface>( injector );
    

    Actual Behavior

       auto injector = di::make_injector(
            // the to be injected parameters but without defined ordering
        );
        auto q = injector.create<QInterface>();
    

    For me, the first would be more understandable, as it resembles the usual way to construct something: you pass parameters to it. But I'm not so sure between the consequences of the two designs. Maybe I am too new to boost DI and DI frameworks. Then forgive me and just tell me "read the basics" or w/e.

    opened by a-teammate 6
  • multiple bindings broken with C++17 (VS 15.8)

    multiple bindings broken with C++17 (VS 15.8)

    Expected Behavior

    With Visual Studio 15.8.3 and /std:c++17 compiler flag defined, multiple bindings fails to compile. i.e. code of the form:

    auto injector = di::make_injector( di::bind<interface* []>().to<implementation1, implementation2>>() );

    Which used to be able to be injected using:

    struct example { example(std::vector<std::unique_ptr<interface>> v) {

    This same code used to compile successfully on VS 15.5 with /std:c++17 flag set.

    Actual Behavior

    C:\git\boost-di\example>cl multiple_bindings.cpp -I../include/ /EHsc /std:c++17 Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26726 for x64 Copyright (C) Microsoft Corporation. All rights reserved.

    multiple_bindings.cpp C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.15.26726\include\xmemory0(881): error C2280: 'std::unique_ptr<interface,std::default_delete<_Ty>>::unique_ptr(const std::unique_ptr<_Ty,std::default_delete<_Ty>> &)': attempting to reference a deleted function with [ _Ty=interface > ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.15.26726\include\memory(2337): note: see declaration of 'std::unique_ptr<interface,std::default_delete<_Ty>>::unique_ptr' with [ _Ty=interface > ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.15.26726\include\memory(2337): note: 'std::unique_ptr<interface,std::default_delete<_Ty>>::unique_ptr(const std::unique_ptr<_Ty,std::default_delete<_Ty>> &)': function was explicitly deleted with [ _Ty=interface > ]

    C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.15.26726\include\xmemory(163): note: see reference to function template instantiation 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,_Ty&>(_Alloc &,_Objty const ,_Ty &)' being compiled with [ _Alloc=std::allocator<std::unique_ptr<interface,std::default_delete>>, _Ty=std::unique_ptr<interface,std::default_delete>, _Objty=std::unique_ptr<interface,std::default_delete> > ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.15.26726\include\xmemory(164): note: see reference to function template instantiation 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,_Ty&>(_Alloc &,_Objty const ,_Ty &)' being compiled with [ _Alloc=std::allocator<std::unique_ptr<interface,std::default_delete>>, _Ty=std::unique_ptr<interface,std::default_delete>, _Objty=std::unique_ptr<interface,std::default_delete> > ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.15.26726\include\xmemory(190): note: see reference to function template instantiation 'void std::_Uninitialized_backout_al<_FwdIt,_Alloc>::_Emplace_back<_Ty&>(_Ty &)' being compiled with [ _FwdIt=std::unique_ptr<interface,std::default_delete> *, _Alloc=std::allocator<std::unique_ptr<interface,std::default_delete>>, _Ty=std::unique_ptr<interface,std::default_delete> > ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.15.26726\include\xmemory(190): note: see reference to function template instantiation 'void std::_Uninitialized_backout_al<_FwdIt,_Alloc>::_Emplace_back<_Ty&>(_Ty &)' being compiled with [ _FwdIt=std::unique_ptr<interface,std::default_delete> *, _Alloc=std::allocator<std::unique_ptr<interface,std::default_delete>>, _Ty=std::unique_ptr<interface,std::default_delete> > ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.15.26726\include\xmemory(217): note: see reference to function template instantiation '_FwdIt std::_Uninitialized_copy_al_unchecked<_Ty,_Ty,_Alloc>(_InIt,const _InIt,const _FwdIt,_Alloc &,std::_General_ptr_iterator_tag,std::_Any_tag)' being compiled with [ _FwdIt=std::unique_ptr<interface,std::default_delete> *, _Ty=std::unique_ptr<interface,std::default_delete>, _Alloc=std::allocator<std::unique_ptr<interface,std::default_delete>>, _InIt=std::unique_ptr<interface,std::default_delete> * > ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.15.26726\include\vector(1823): note: see reference to function template instantiation '_FwdIt std::_Uninitialized_copy<_Iter,std::unique_ptr<interface,std::default_delete<_Ty>>,std::allocator<std::unique_ptr<_Ty,std::default_delete<_Ty>>>>(const _InIt,const _InIt,_FwdIt,_Alloc &)' being compiled with [ _FwdIt=std::unique_ptr<interface,std::default_delete> *, _Iter=std::unique_ptr<interface,std::default_delete> *, _Ty=interface, _InIt=std::unique_ptr<interface,std::default_delete> *, _Alloc=std::allocator<std::unique_ptr<interface,std::default_delete>> > ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.15.26726\include\vector(738): note: see reference to function template instantiation 'std::unique_ptr<interface,std::default_delete<_Ty>> std::vector<std::unique_ptr<_Ty,std::default_delete<_Ty>>,std::allocator<std::unique_ptr<_Ty,std::default_delete<_Ty>>>>::_Ucopy<std::unique_ptr<_Ty,std::default_delete<_Ty>>>(_Iter,_Iter,std::unique_ptr<_Ty,std::default_delete<_Ty>> *)' being compiled with [ _Ty=interface, _Iter=std::unique_ptr<interface,std::default_delete> * > ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.15.26726\include\vector(738): note: see reference to function template instantiation 'std::unique_ptr<interface,std::default_delete<_Ty>> std::vector<std::unique_ptr<_Ty,std::default_delete<_Ty>>,std::allocator<std::unique_ptr<_Ty,std::default_delete<_Ty>>>>::_Ucopy<std::unique_ptr<_Ty,std::default_delete<_Ty>>>(_Iter,_Iter,std::unique_ptr<_Ty,std::default_delete<_Ty>> *)' being compiled with [ _Ty=interface, _Iter=std::unique_ptr<interface,std::default_delete> * > ] C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.15.26726\include\vector(732): note: while compiling class template member function 'std::vector<std::unique_ptr<interface,std::default_delete<_Ty>>,std::allocator<std::unique_ptr<_Ty,std::default_delete<_Ty>>>>::vector(const std::vector<std::unique_ptr<_Ty,std::default_delete<_Ty>>,std::allocator<std::unique_ptr<_Ty,std::default_delete<_Ty>>>> &)' with [ _Ty=interface > ] ../include/boost/di.hpp(1324): note: see reference to function template instantiation 'std::vector<std::unique_ptr<interface,std::default_delete<_Ty>>,std::allocator<std::unique_ptr<_Ty,std::default_delete<_Ty>>>>::vector(const std::vector<std::unique_ptr<_Ty,std::default_delete<_Ty>>,std::allocator<std::unique_ptr<_Ty,std::default_delete<_Ty>>>> &)' being compiled with [ _Ty=interface > ] multiple_bindings.cpp(35): note: see reference to class template instantiation 'std::vector<std::unique_ptr<interface,std::default_delete<_Ty>>,std::allocator<std::unique_ptr<_Ty,std::default_delete<_Ty>>>>' being compiled with [ _Ty=interface > ]

    Steps to Reproduce the Problem

    1. Attempt to compile the example/multiple_bindings.cpp file using Visual Studio 15.8.3 with C++17 language enabled:

    C:\git\boost-di\example>cl multiple_bindings.cpp -I../include/ /EHsc /std:c++17

    Specifications

    • Version: latest git revision 57659cfb018dcb36037a1d6c83a5d868827329da (branch cpp14)
    • Platform: Windows (Visual Studio 15.8.3)

    Any idea how to fix this? Thanks!

    bug 
    opened by scottmcnab 6
  • Impossible to create shared_ptr on class with Private copy or move constructor

    Impossible to create shared_ptr on class with Private copy or move constructor

    I use this simple example to present my problem. In my original issue I can't use a copy or a move constructor due to limitation of external heritage where those constructors are private.

    This is the only reason why I need to use a shared_ptr... but it doesn't work needer with pointer.

    #include <memory>
    #include <boost/di.hpp>
    namespace di = boost::di;
    
    class S{};
    
    class C
    {
    public:
    	virtual ~C(){};
    	C(){};
    	virtual bool Done() const = 0;
    private: /*Remove it to control*/
    	C(C &&) {};
    	C(const C &) {};
    };
    
    class Cc : public C
    {
    public:
    	Cc(S* const s) :
    		m_s{s} {}
    
    	virtual bool Done() const
    	{	return false; 	}
    private: /*Remove it to control*/
    	Cc(Cc &&c) : 
    		C(std::move(c))
    	{ 	m_s = std::move(c.m_s); }
    	Cc(const Cc &c) : C(c)
    	{	m_s = c.m_s; }
    
    private:
    	S* m_s;
    };
    
    int main()
    {
    	S* const s = new S();
    	auto injector = di::make_injector(
    		di::bind<C>().to<Cc>(),
    		di::bind<S>().to(s)
    	  );
    	return injector.create<std::shared_ptr<C>>()->Done() == true;
    }
    

    I think the object should be created accordingly to his final format before being moved... or I'm doing something wrong !

    Thanks the consideration and your amazing work !

    usage question 
    opened by AxelVE 6
  • Are you going to release a new version? Add support for C++20 with Visual Studio 2022 generator.

    Are you going to release a new version? Add support for C++20 with Visual Studio 2022 generator.

    I see version v1.2.0 was released Jul 22, 2020 (two years ago). There are several fixes in the main branch till then.

    Are there any plans to make a newer release (tag)? I also see that there is a problem compiling tests and examples with Visual Studio 2022 and specifying c++ version 20 - using CMake and Visual Studio as a generator.

    Expected Behavior

    Tests and examples should compile successfully and tests should pass using Visual Studio 2022 generator and specifying C++20

    Actual Behavior

    Compilation using Visual Studio 2022 generator and specifying C++20 support fails for some tests and examples.

    Specifications

    • Version: v1.2.0
    • Platform: Windows
    • Subsystem: Visual Studio 2022 generator with C++20 CMAKE_CXX_STANDARD
    opened by dmitry-diolan 0
  • Can Boost DI be used with C language?

    Can Boost DI be used with C language?

    Expected Behavior

    I want to use Boost DI for C projects, as well as C++ projects

    Actual Behavior

    I don't know, if it's going to work with C language

    Steps to Reproduce the Problem

    Specifications

    • Version: -
    • Platform: -
    • Subsystem: -
    opened by ovirovkin 0
  • test.policies_serialize ..........Subprocess aborted (OSX)

    test.policies_serialize ..........Subprocess aborted (OSX)

    Expected Behavior

    No errors and no Warnings

    Actual Behavior

    bash-3.2$ ctest --rerun-failed --output-on-failure
    Test project /Users/clausklein/Workspace/cpp/boost-ext/di/build
        Start 10: test.policies_serialize
    1/1 Test #10: test.policies_serialize ..........Subprocess aborted***Exception:   0.00 sec
    libc++abi: terminating with uncaught exception of type std::length_error: basic_string
    
    
    0% tests passed, 1 tests failed out of 1
    
    Total Test time (real) =   0.01 sec
    
    The following tests FAILED:
    	 10 - test.policies_serialize (Subprocess aborted)
    Errors while running CTest
    bash-3.2$ 
    

    Steps to Reproduce the Problem

    cmake -B build -G Ninja
    ninja -C build/
    ninja -C build/ test
    cd build
    ctest --rerun-failed --output-on-failure
    

    Specifications

    • Version: CMAKE_CXX_STANDARD=14
    • Platform: OSX
    • Subsystem:

    see too https://github.com/ClausKlein/di/actions/runs/2140491208

    opened by ClausKlein 0
  • error: definition of implicit copy constructor for 'app' is deprecated (OSX)

    error: definition of implicit copy constructor for 'app' is deprecated (OSX)

    Expected Behavior

    No errors and no warnings

    Actual Behavior

    bash-3.2$ cmake -B build -G Ninja  
    CMake Deprecation Warning at CMakeLists.txt:7 (cmake_minimum_required):
      Compatibility with CMake < 2.8.12 will be removed from a future version of
      CMake.
    
      Update the VERSION argument <min> value or use a ...<max> suffix to tell
      CMake that the project does not need compatibility with older versions.
    
    
    -- The CXX compiler identification is AppleClang 13.1.6.13160021
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /Users/clausklein/Workspace/cpp/boost-ext/di/build
    bash-3.2$ cd build
    bash-3.2$ ninja
    [200/314] Building CXX object example/CMakeFiles/example.bindings.dir/bindings.cpp.o
    FAILED: example/CMakeFiles/example.bindings.dir/bindings.cpp.o 
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++  -I/Users/clausklein/Workspace/cpp/boost-ext/di/example/.. -I/Users/clausklein/Workspace/cpp/boost-ext/di/include -I/Users/clausklein/Workspace/cpp/boost-ext/di/extension/include -std=c++1y -fno-exceptions -pedantic -pedantic-errors -Wall -Wextra -Werror -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -MD -MT example/CMakeFiles/example.bindings.dir/bindings.cpp.o -MF example/CMakeFiles/example.bindings.dir/bindings.cpp.o.d -o example/CMakeFiles/example.bindings.dir/bindings.cpp.o -c /Users/clausklein/Workspace/cpp/boost-ext/di/example/bindings.cpp
    /Users/clausklein/Workspace/cpp/boost-ext/di/example/bindings.cpp:58:8: error: definition of implicit copy constructor for 'app' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
      app& operator=(const app&) = delete;
           ^
    /Users/clausklein/Workspace/cpp/boost-ext/di/example/bindings.cpp:88:22: note: in implicit copy constructor for 'app' first required here
      auto service_app = injector.create<app>();
                         ^
    1 error generated.
    [213/314] Building CXX object test/CMakeFiles/test.ft_di_bind.dir/ft/di_bind.cpp.o
    ninja: build stopped: subcommand failed.
    bash-3.2$ git status
    On branch cpp14
    Your branch is up to date with 'origin/cpp14'.
    bash-3.2$
    

    Specifications

    • Version: HEAD -> cpp14
    • Platform: OSX
    • Subsystem:
    opened by ClausKlein 0
  • Errors while running CTest on Ubuntu with clang++ v12

    Errors while running CTest on Ubuntu with clang++ v12

    Expected Behavior

    No Warning and all test passed

    Actual Behavior

    :~/Workspace/cpp/boost-ext/di/build$ ctest --rerun-failed --output-on-failure
    Test project ~/Workspace/cpp/boost-ext/di/build
        Start 10: test.policies_serialize
    1/2 Test #10: test.policies_serialize ..........Subprocess aborted***Exception:   0.01 sec
    terminate called after throwing an instance of 'std::length_error'
      what():  basic_string::_M_create
    
        Start 64: test.ft_di_injector
    2/2 Test #64: test.ft_di_injector ..............***Failed    0.01 sec
    ~/Workspace/cpp/boost-ext/di/test/ft/di_injector.cpp:343:42 == object->i
    
    
    0% tests passed, 2 tests failed out of 2
    
    Total Test time (real) =   0.03 sec
    
    The following tests FAILED:
             10 - test.policies_serialize (Subprocess aborted)
             64 - test.ft_di_injector (Failed)
    Errors while running CTest
    ~/Workspace/cpp/boost-ext/di/build$
    

    Steps to Reproduce the Problem

    1. CXX=clang++ cmake -G Ninja -B build
    2. cd build
    3. ninja
    4. ctest

    Specifications

    • Version: v1.2.0
    • Platform: Ubuntu
    • Subsystem: clang version 12.0.0-3ubuntu1~20.04.4
    opened by ClausKlein 0
Releases(v1.2.0)
Owner
boost::ext
Modern C++ libraries (not officially in Boost)
boost::ext
🌱Light and powerful C++ web framework for highly scalable and resource-efficient web application. It's zero-dependency and easy-portable.

Oat++ News Hey, meet the new oatpp version 1.2.5! See the changelog for details. Check out the new oatpp ORM - read more here. Oat++ is a modern Web F

Oat++ 5.7k Sep 21, 2022
Wireless keystroke injection attack platform

Wireless keystroke injection attack platform

Spacehuhn Technologies 1.4k Sep 20, 2022
Mongoose Embedded Web Server Library - a multi-protocol embedded networking library with TCP/UDP, HTTP, WebSocket, MQTT built-in protocols, async DNS resolver, and non-blocking API.

Mongoose - Embedded Web Server / Embedded Networking Library Mongoose is a networking library for C/C++. It implements event-driven non-blocking APIs

Cesanta Software 8.7k Sep 18, 2022
C Hypertext Library - A library for writing web applications in C

CHL C Hypertext Library - A library for writing web applications in C #include <chl/chl.h> int main() { chl_set_default_headers(); chl_print_header

null 273 Aug 15, 2022
The C++ Network Library Project -- cross-platform, standards compliant networking library.

C++ Network Library Modern C++ network programming libraries. Join us on Slack: http://slack.cpp-netlib.org/ Subscribe to the mailing list: https://gr

C++ Network Library 1.9k Sep 22, 2022
C++ peer to peer library, built on the top of boost

Breep What is Breep? Breep is a c++ bridged peer to peer library. What does that mean? It means that even though the network is constructed as a peer

Lucas Lazare 111 Aug 31, 2022
Cross-platform, efficient, customizable, and robust asynchronous HTTP/WebSocket server C++14 library with the right balance between performance and ease of use

What Is RESTinio? RESTinio is a header-only C++14 library that gives you an embedded HTTP/Websocket server. It is based on standalone version of ASIO

Stiffstream 882 Sep 19, 2022
A C library for asynchronous DNS requests

c-ares This is c-ares, an asynchronous resolver library. It is intended for applications which need to perform DNS queries without blocking, or need t

c-ares 1.5k Sep 18, 2022
A C++ header-only HTTP/HTTPS server and client library

cpp-httplib A C++11 single-file header-only cross platform HTTP/HTTPS library. It's extremely easy to setup. Just include the httplib.h file in your c

null 7.8k Sep 26, 2022
Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution

CppServer Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and

Ivan Shynkarenka 885 Sep 17, 2022
ENet reliable UDP networking library

Please visit the ENet homepage at http://enet.bespin.org for installation and usage instructions. If you obtained this package from github, the quick

Lee Salzman 2.2k Sep 21, 2022
A modern C++ network library for developing high performance network services in TCP/UDP/HTTP protocols.

evpp Introduction 中文说明 evpp is a modern C++ network library for developing high performance network services using TCP/UDP/HTTP protocols. evpp provid

Qihoo 360 3.1k Sep 22, 2022
C++ library for creating an embedded Rest HTTP server (and more)

The libhttpserver reference manual Tl;dr libhttpserver is a C++ library for building high performance RESTful web servers. libhttpserver is built upon

Sebastiano Merlino 683 Sep 17, 2022
The Apache Kafka C/C++ library

librdkafka - the Apache Kafka C/C++ client library Copyright (c) 2012-2020, Magnus Edenhill. https://github.com/edenhill/librdkafka librdkafka is a C

Magnus Edenhill 6.2k Sep 16, 2022
canonical libwebsockets.org networking library

Libwebsockets Libwebsockets is a simple-to-use, MIT-license, pure C library providing client and server for http/1, http/2, websockets, MQTT and other

lws-team 3.6k Sep 17, 2022
Event-driven network library for multi-threaded Linux server in C++11

Muduo is a multithreaded C++ network library based on the reactor pattern. http://github.com/chenshuo/muduo Copyright (c) 2010, Shuo Chen. All righ

Shuo Chen 12k Sep 26, 2022
nghttp2 - HTTP/2 C Library and tools

nghttp2 - HTTP/2 C Library This is an implementation of the Hypertext Transfer Protocol version 2 in C. The framing layer of HTTP/2 is implemented as

nghttp2 4.1k Sep 16, 2022
C library to create simple HTTP servers and Web Applications.

Onion http server library Travis status Coverity status Onion is a C library to create simple HTTP servers and Web Applications. master the developmen

David Moreno Montero 1.9k Sep 17, 2022
Single C file TLS 1.2/1.3 implementation, using tomcrypt as crypto library

TLSe Single C file TLS 1.3, 1.2, 1.1 and 1.0(without the weak ciphers) implementation, using libtomcrypt as crypto library. It also supports DTLS 1.2

Eduard Suica 457 Sep 21, 2022