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

Array and map construction #9

Closed
breese opened this issue Mar 12, 2017 · 1 comment
Closed

Array and map construction #9

breese opened this issue Mar 12, 2017 · 1 comment

Comments

@breese
Copy link
Owner

breese commented Mar 12, 2017

On the feature/dynamic branch it is possible to construct a dynamic::variable by passing a variable::array_type (aka std::vector<variable>.) I want to change this to used named constructors instead.

For example, the following code:

std::vector<variable> values;
variable data(values);

should be changed into:

std::variable<variable> values;
variable data = variable::array(values.begin(), values.end());

The reason for this change is that the current code can lead to surprising results. While working on adding support for operator<< I encountered an infinite recursion because operator<<(variable) was invoked when given a std::vector<variable>.

I could have solved the recursion by adding an overload for std::vector<variable> but that would preclude users from adding their own. Notice that operator<<(variable) simply forwards to operator<< of the underlying type, so the default behaviour of operator<<(std::vector<variable>) should be a compiler error (unless a custom overload exists.) It is not used for serialization.

All of the above also applies to variable::map_type.

Any objections?

@vinipsmaker
Copy link
Contributor

Any objections?

Not from my side.

@breese breese closed this as completed Apr 6, 2017
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