di icon indicating copy to clipboard operation
di copied to clipboard

Incomplete types

Open marco6 opened this issue 5 years ago • 0 comments

I really like this library and I'd really want to use it together with a C library (namely, libpq).

The main problem is that it seems not possible to bind pointers to incomplete types. This workaround won't work as dereferencing the pointer at line 16 will result in a compile error.

Expected Behavior

Being able to work with incomplete types.

Actual Behavior

Does not compile/there is no syntax to express this kind of binding.

Steps to Reproduce the Problem


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

using namespace std;
namespace DI = boost::di;

struct kkp;

static kkp* get_kkp(void);

int main(int argc, const char** argv) {

	auto injector = DI::make_injector(
		DI::bind<>.to([] {
			return get_kkp();
		})
	);

	injector.create<kkp*>();
}

struct kkp {
	int a;
	kkp(int _a): a(_a) {
		cout << a << endl;
	}
};

static kkp* get_kkp() {
	return new kkp(10);
}

This results in creatable constraint not satisfied.

Specifications

  • Version: 1.1.0
  • Platform: Ubuntu 18.10
  • Subsystem: g++ 8.3.0

marco6 avatar May 29 '19 20:05 marco6