Skip to content

Commit

Permalink
visual studio wont compile without this change
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanMcGorty committed Apr 4, 2018
1 parent cf83f0c commit 2a6495f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
31 changes: 19 additions & 12 deletions algebraic_virtual.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,24 @@ constexpr size_t largest_class()
template<typename subset_first, typename...subset>
struct is_subset
{
template<typename...superset>
static constexpr bool of()
{
if constexpr(sizeof...(subset) == 0)
{
return is_one_of<subset_first,superset...>();
}
else
{
return is_one_of<subset_first,superset...>() && is_subset<subset...>::template of<superset...>();
}
}

template<typename...superset>
static constexpr bool of()
{

return is_one_of<subset_first, superset...>() && is_subset<subset...>::template of<superset...>();

}
};

template<typename subset_only>
struct is_subset<subset_only>
{
template<typename...superset>
static constexpr bool of()
{
return is_one_of<subset_only, superset...>();
}
};

template<typename...list>
Expand Down Expand Up @@ -171,6 +177,7 @@ class algebraic
data.assign(std::move(a.data), a.is_nullval() ? &null_mover<oldbase>::move_construct : a.move_functor());
}


~algebraic() noexcept(true)
{}

Expand Down
30 changes: 12 additions & 18 deletions free-store_virtual.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,30 @@ friend class virt;

template<typename d>
//move construction and implicit upcast construction
virt(virt<d>&& a) :
virt(virt<d>&& a) noexcept(true) :
data(static_cast<d*>(a.data.release()))
{
static_assert(std::is_base_of<t,d>::value || std::is_same<t,d>::value,"to construct virt<x> from virt<y>&&, x must be the same as or derive from y");
}

template<typename d>
//move assignment and implicit upcast assignment
void operator=(virt<d>&& a)
void operator=(virt<d>&& a) noexcept(true)
{
static_assert(std::is_base_of<t,d>::value || std::is_same<t,d>::value,"to assign to virt<x> from virt<y>&&, x must be the same as or derive from y");
data.reset(std::move(static_cast<d*>(a.data.release())));
}

template<typename d>
virt(virt<d> const& a) = delete;

template<typename d>
void operator=(virt<d> const& a) = delete;

virt(virt const& a) = delete;

void operator=(virt const& a) = delete;


//like implicit upcasting
template<typename b>
Expand All @@ -76,22 +86,6 @@ friend class virt;
static_assert(std::is_base_of<b,t>::value || std::is_same<b,t>::value,"to upcast virt<x>&& to virt<y>, x must derive from y");
return virt<b>{std::unique_ptr<b>{static_cast<b*>(data.release())}};
}

// //like implicit upcasting
// template<typename b>
// b* upcast_get()
// {
// static_assert(std::is_base_of<b,t>::value || std::is_same<b,t>::value,"to upcast virt<x>&& to virt<y>, x must derive from y");
// return static_cast<b*>(data.get());
// }

// //like implicit upcasting
// template<typename b>
// b const* upcast_get() const
// {
// static_assert(std::is_base_of<b,t>::value || std::is_same<b,t>::value,"to upcast virt<x>&& to virt<y>, x must derive from y");
// return static_cast<b const*>(data.get());
// }

//like trying a dynamic cast
template<typename d>
Expand Down

0 comments on commit 2a6495f

Please sign in to comment.