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

Incomplete types #425

Open
marco6 opened this issue May 29, 2019 · 1 comment
Open

Incomplete types #425

marco6 opened this issue May 29, 2019 · 1 comment

Comments

@marco6
Copy link

marco6 commented May 29, 2019

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
@feltech
Copy link

feltech commented Feb 18, 2025

Would definitely be interested in this one. Incomplete types (C handles) crop up quite frequently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants