Skip to content

Commit

Permalink
Fix Wdeprecated-copy in wfl::variant, and add move operations
Browse files Browse the repository at this point in the history
Fixes the majority of the warnings in issue #4166.

This class already shared copies of value_ between instances,
it seems to be the immutable design pattern so can share from
const to non-const instances safely.

Cherry-picking this to 1.14 needs a trivial conflict to be
resolved, the next line in the .cpp file has changed from
size_t in 1.14 to std::size_t in 1.15.
  • Loading branch information
stevecotton authored and Vultraz committed Jul 15, 2019
1 parent 1fac6ac commit eabf933
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 0 additions & 6 deletions src/formula/variant.cpp
Expand Up @@ -180,12 +180,6 @@ variant::variant(const std::map<variant,variant>& map)
assert(value_.get());
}

variant& variant::operator=(const variant& v)
{
value_ = v.value_;
return *this;
}

variant variant::operator[](std::size_t n) const
{
if(is_callable()) {
Expand Down
5 changes: 4 additions & 1 deletion src/formula/variant.hpp
Expand Up @@ -36,6 +36,8 @@ class variant
explicit variant(const std::vector<variant>& array);
explicit variant(const std::string& str);
explicit variant(const std::map<variant, variant>& map);
variant(const variant& v) = default;
variant(variant&& v) = default;

template<typename T>
variant(std::shared_ptr<T> callable)
Expand All @@ -44,7 +46,8 @@ class variant
assert(value_.get());
}

variant& operator=(const variant& v);
variant& operator=(const variant& v) = default;
variant& operator=(variant&& v) = default;

variant operator[](std::size_t n) const;
variant operator[](const variant& v) const;
Expand Down

0 comments on commit eabf933

Please sign in to comment.