boost-ext / di

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

Template binding std::vector #335

Closed SimonEbner closed 6 years ago

SimonEbner commented 6 years ago

Compiling the following program works for T=std::vector but not for T=std::vector<std::string>

#include <type_traits>
#include "di.hpp"

namespace di = boost::di;
using T = std::vector<std::string>;

template<typename Impl=class Interface>
struct X{
    X(Impl& x) { static_assert(std::is_same<Impl, T>::value, "E"); }
};

int main() {
    di::make_injector(
        di::bind<Interface>.to<T>()
    ).create<X>();
}

Expected Behavior

Program compiles without errors for using T = std::string and using T = std::vector<std::string>

Actual Behavior

Program compiles without errors for T=std::string but produces many errors for T = std::vector<std::string>, starting with the following error

di.hpp:358:3: error: static assertion failed: constraint not satisfied
   static_assert(T::value, "constraint not satisfied");

The full log is attached. err.txt

Specifications