Skip to content

Commit

Permalink
c++ : better names (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemp committed Feb 12, 2014
1 parent 68aa114 commit 48dd833
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions variant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,30 +86,30 @@ struct variant_helper<T, Types...>
}
}

VARIANT_INLINE static void move(const std::size_t old_t, void * old_v, void * new_v)
VARIANT_INLINE static void move(const std::size_t old_id, void * old_value, void * new_value)
{
if (old_t == sizeof...(Types))
if (old_id == sizeof...(Types))
{
new (new_v) T(std::move(*reinterpret_cast<T*>(old_v)));
new (new_v) T(std::move(*reinterpret_cast<T*>(old_value)));
//std::memcpy(new_v, old_v, sizeof(T));
// ^^ DANGER: this should only be considered for relocatable types e.g built-in types
// Also, I don't see any measurable performance benefit just yet
}
else
{
variant_helper<Types...>::move(old_t, old_v, new_v);
variant_helper<Types...>::move(old_id, old_value, new_value);
}
}

VARIANT_INLINE static void copy(const std::size_t old_t, const void * old_v, void * new_v)
VARIANT_INLINE static void copy(const std::size_t old_id, const void * old_value, void * new_value)
{
if (old_t == sizeof...(Types))
if (old_id == sizeof...(Types))
{
new (new_v) T(*reinterpret_cast<const T*>(old_v));
new (new_v) T(*reinterpret_cast<const T*>(old_value));
}
else
{
variant_helper<Types...>::copy(old_t, old_v, new_v);
variant_helper<Types...>::copy(old_id, old_value, new_value);
}
}
};
Expand Down

0 comments on commit 48dd833

Please sign in to comment.