Skip to content

Commit

Permalink
Make variant constructor from std::shared_ptr a template
Browse files Browse the repository at this point in the history
For some reason, when the variant constructor only accepts
std::shared_ptr<const variant_callable>, MSVC2013 gets confused about which
constructor it should call when it has, say,
std::shared_ptr<ai::attack_analysis>. Making the constructor a template
fixes it.
  • Loading branch information
jyrkive authored and CelticMinstrel committed Apr 8, 2017
1 parent d536d6a commit 0b02ba0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 0 additions & 6 deletions src/formula/variant.cpp
Expand Up @@ -162,12 +162,6 @@ variant::variant(double n, variant::DECIMAL_VARIANT_TYPE)
assert(value_.get());
}

variant::variant(const_formula_callable_ptr callable)
: value_(std::make_shared<variant_callable>(callable))
{
assert(value_.get());
}

variant::variant(const std::vector<variant>& vec)
: value_((std::make_shared<variant_list>(vec)))
{
Expand Down
8 changes: 7 additions & 1 deletion src/formula/variant.hpp
Expand Up @@ -34,11 +34,17 @@ class variant
explicit variant(int n);
variant(int n, DECIMAL_VARIANT_TYPE /*type*/);
variant(double n, DECIMAL_VARIANT_TYPE /*type*/);
variant(const_formula_callable_ptr callable);
explicit variant(const std::vector<variant>& array);
explicit variant(const std::string& str);
explicit variant(const std::map<variant, variant>& map);

template<typename T>
variant(std::shared_ptr<T> callable)
: value_(std::make_shared<variant_callable>(callable))
{
assert(value_.get());
}

variant& operator=(const variant& v);

variant operator[](size_t n) const;
Expand Down

0 comments on commit 0b02ba0

Please sign in to comment.