boost-ext / di

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

Injector creation fails if object is subclass of gRPC service #470

Open jheaff1 opened 4 years ago

jheaff1 commented 4 years ago

Expected Behavior

The following should successfully compile

  auto injector = di::make_injector(di::bind<api::MyGrpcApi::Service>.to<MyGrpcApiServiceImpl>());
  auto grpc_service_imp =  injector.create<MyGrpcApiServiceImpl>();

Actual Behavior

The compilation error is:

In file included from /usr/include/c++/7/memory:64:0,
                 from /usr/local/include/grpcpp/channel_impl.h:22,
                 from /usr/local/include/grpcpp/channel.h:22,
                 from /usr/local/include/grpcpp/grpcpp.h:52,
                 from /home/name/git/app/src/entrypoint.cc:3:
/usr/include/c++/7/bits/stl_construct.h: In instantiation of 'void std::_Construct(_T1*, _Args&& ...) [with _T1 = std::unique_ptr<grpc::internal::RpcServiceMethod>; _Args = {const std::unique_ptr<grpc::internal::RpcServiceMethod, std::default_delete<grpc::internal::RpcServiceMethod> >&}]':
/usr/include/c++/7/bits/stl_uninitialized.h:83:18:   required from 'static _ForwardIterator std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const std::unique_ptr<grpc::internal::RpcServiceMethod>*, std::vector<std::unique_ptr<grpc::internal::RpcServiceMethod> > >; _ForwardIterator = std::unique_ptr<grpc::internal::RpcServiceMethod>*; bool _TrivialValueTypes = false]'
/usr/include/c++/7/bits/stl_uninitialized.h:134:15:   required from '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const std::unique_ptr<grpc::internal::RpcServiceMethod>*, std::vector<std::unique_ptr<grpc::internal::RpcServiceMethod> > >; _ForwardIterator = std::unique_ptr<grpc::internal::RpcServiceMethod>*]'
/usr/include/c++/7/bits/stl_uninitialized.h:289:37:   required from '_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = __gnu_cxx::__normal_iterator<const std::unique_ptr<grpc::internal::RpcServiceMethod>*, std::vector<std::unique_ptr<grpc::internal::RpcServiceMethod> > >; _ForwardIterator = std::unique_ptr<grpc::internal::RpcServiceMethod>*; _Tp = std::unique_ptr<grpc::internal::RpcServiceMethod>]'
/usr/include/c++/7/bits/stl_vector.h:331:31:   required from 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::unique_ptr<grpc::internal::RpcServiceMethod>; _Alloc = std::allocator<std::unique_ptr<grpc::internal::RpcServiceMethod> >]'
/usr/local/include/grpcpp/impl/codegen/service_type.h:60:7:   required from here
/usr/include/c++/7/bits/stl_construct.h:75:7: error: use of deleted function 'std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = grpc::internal::RpcServiceMethod; _Dp = std::default_delete<grpc::internal::RpcServiceMethod>]'
     { ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/7/memory:80:0,
                 from /usr/local/include/grpcpp/channel_impl.h:22,
                 from /usr/local/include/grpcpp/channel.h:22,
                 from /usr/local/include/grpcpp/grpcpp.h:52,
                 from /home/name/git/app/src/entrypoint.cc:3:
/usr/include/c++/7/bits/unique_ptr.h:383:7: note: declared here
       unique_ptr(const unique_ptr&) = delete;

Steps to Reproduce the Problem

  1. Create a gRPC service implementation class, which is inherits from the service class generated from the gRPC service protobuf file
  2. Attempt to create an injector for the gRPC service implementation class
  3. Compilation error

Specifications