Skip to content

Commit

Permalink
Add compile time check to disallow array types as alternatives.
Browse files Browse the repository at this point in the history
  • Loading branch information
artemp committed Feb 6, 2017
1 parent fa8e124 commit 3f6fd13
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions include/mapbox/variant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,10 @@ struct no_init {};
template <typename... Types>
class variant
{
static_assert(sizeof...(Types) > 0, "Template parameter type list of variant can not be empty");
static_assert(sizeof...(Types) > 0, "Template parameter type list of variant can not be empty.");
static_assert(!detail::disjunction<std::is_reference<Types>...>::value, "Variant can not hold reference types. Maybe use std::reference_wrapper?");
static_assert(sizeof...(Types) < std::numeric_limits<type_index_t>::max(), "Internal index type must be able to accommodate all alternatives");
static_assert(!detail::disjunction<std::is_array<Types>...>::value, "Variant can not hold array types.");
static_assert(sizeof...(Types) < std::numeric_limits<type_index_t>::max(), "Internal index type must be able to accommodate all alternatives.");
private:
static const std::size_t data_size = detail::static_max<sizeof(Types)...>::value;
static const std::size_t data_align = detail::static_max<alignof(Types)...>::value;
Expand Down

0 comments on commit 3f6fd13

Please sign in to comment.