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

Compilation issue when using std::future #47

Open
gelldur opened this issue Dec 5, 2022 · 4 comments
Open

Compilation issue when using std::future #47

gelldur opened this issue Dec 5, 2022 · 4 comments

Comments

@gelldur
Copy link
Owner

gelldur commented Dec 5, 2022

/home/X/.cache/X/prebuild/X/install-Debug/include/dexode/eventbus/Bus.hpp:82:23: error: no matching function for call to 'create'
                auto postponeCall = PostponeHelper::create<Event>(std::move(event));
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/X/Project/X/X/src/backend/BackendApplication.cpp:124:14: note: in instantiation of function template specialization 'dexode::eventbus::Bus::postpone<event::backend::XYZ>' requested here
                                        guiBus->postpone(event::backend::XYZ{
                                                ^
/home/X/.cache/X/prebuild/X/install-Debug/include/dexode/eventbus/Bus.hpp:54:24: note: candidate function template not viable: no known conversion from 'typename std::remove_reference<XYZ &>::type' (aka 'event::backend::XYZ') to 'std::any' for 1st argument
        static PostponeHelper create(std::any&& event)

Example:

	guiBus->postpone(event::backend::XYZ{
		"text",
		std::async(std::launch::deferred, [state]() { return state->state(); })})

I would expect either working or more clear compile error. Maybe everything is ok but should work I guess...

@gelldur
Copy link
Owner Author

gelldur commented Dec 5, 2022

Ok issue is in unclear compilation error this is reason:

error: call to implicitly-deleted copy constructor of 'event::backend::XYZ'

@gelldur
Copy link
Owner Author

gelldur commented Dec 5, 2022

Notes:

  1. Event state can't be mutable.
    Interesting use case when we would like to "cache" result of deferred async task. Need to write wrapper for such future?

@panmaksym
Copy link

Is this problem solved? If not, I could look at it, it would be interesting to understand

@gelldur
Copy link
Owner Author

gelldur commented Jun 5, 2023

Yeah still valid issue. Not sure what correct solution would be as mentioned above of mutable state of event.

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

No branches or pull requests

2 participants