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

Allow support of initializer lists in Zserio optional #57

Open
mikir opened this issue Dec 11, 2024 · 0 comments
Open

Allow support of initializer lists in Zserio optional #57

mikir opened this issue Dec 11, 2024 · 0 comments
Milestone

Comments

@mikir
Copy link
Collaborator

mikir commented Dec 11, 2024

Zserio Optional assignment and emplace() are not working on initializer lists. The reason is that template parameters cannot be deduced. Example:

typedef zserio::Optional<std::vector<int>> OptionalVectorInt;
OptionalVectorInt v;    
v = {4};

The previous example is not compilable and returns an error "couldn’t deduce template parameter ‘U’"

Consider to use something like

BasicOptional& operator=(T&& value)
{
    emplace(std::forward<T>(value));
    return *this;
}

Reported by @reinco.

@mikir mikir added this to the Backlog milestone Dec 11, 2024
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

1 participant