Update repo to conform to openbmc code standard
Change-Id: If1d6b1f04514367cc544c2507a845b3e9d6d3435
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/mapbox/recursive_wrapper.hpp b/mapbox/recursive_wrapper.hpp
index 4ffcbd7..af569ef 100644
--- a/mapbox/recursive_wrapper.hpp
+++ b/mapbox/recursive_wrapper.hpp
@@ -15,11 +15,12 @@
#include <cassert>
#include <utility>
-namespace mapbox {
-namespace util {
+namespace mapbox
+{
+namespace util
+{
-template <typename T>
-class recursive_wrapper
+template <typename T> class recursive_wrapper
{
T* p_;
@@ -29,7 +30,7 @@
this->get() = rhs;
}
-public:
+ public:
using type = T;
/**
@@ -41,22 +42,32 @@
* of type T.
* @throws any exception thrown by the default constructur of T.
*/
- recursive_wrapper()
- : p_(new T){}
+ recursive_wrapper() : p_(new T)
+ {
+ }
- ~recursive_wrapper() noexcept { delete p_; }
+ ~recursive_wrapper() noexcept
+ {
+ delete p_;
+ }
- recursive_wrapper(recursive_wrapper const& operand)
- : p_(new T(operand.get())) {}
+ recursive_wrapper(recursive_wrapper const& operand) :
+ p_(new T(operand.get()))
+ {
+ }
- recursive_wrapper(T const& operand)
- : p_(new T(operand)) {}
+ recursive_wrapper(T const& operand) : p_(new T(operand))
+ {
+ }
- recursive_wrapper(recursive_wrapper&& operand)
- : p_(new T(std::move(operand.get()))) {}
+ recursive_wrapper(recursive_wrapper&& operand) :
+ p_(new T(std::move(operand.get())))
+ {
+ }
- recursive_wrapper(T&& operand)
- : p_(new T(std::move(operand))) {}
+ recursive_wrapper(T&& operand) : p_(new T(std::move(operand)))
+ {
+ }
inline recursive_wrapper& operator=(recursive_wrapper const& rhs)
{
@@ -101,13 +112,25 @@
return *get_pointer();
}
- T* get_pointer() { return p_; }
+ T* get_pointer()
+ {
+ return p_;
+ }
- const T* get_pointer() const { return p_; }
+ const T* get_pointer() const
+ {
+ return p_;
+ }
- operator T const&() const { return this->get(); }
+ operator T const&() const
+ {
+ return this->get();
+ }
- operator T&() { return this->get(); }
+ operator T&()
+ {
+ return this->get();
+ }
}; // class recursive_wrapper
diff --git a/mapbox/variant.hpp b/mapbox/variant.hpp
index 5574b67..37c736d 100644
--- a/mapbox/variant.hpp
+++ b/mapbox/variant.hpp
@@ -45,7 +45,7 @@
// clang-format on
// Exceptions
-#if defined( __EXCEPTIONS) || defined( _MSC_VER)
+#if defined(__EXCEPTIONS) || defined(_MSC_VER)
#define HAS_EXCEPTIONS
#endif
@@ -53,52 +53,61 @@
#define VARIANT_MINOR_VERSION 1
#define VARIANT_PATCH_VERSION 0
-#define VARIANT_VERSION (VARIANT_MAJOR_VERSION * 100000) + (VARIANT_MINOR_VERSION * 100) + (VARIANT_PATCH_VERSION)
+#define VARIANT_VERSION \
+ (VARIANT_MAJOR_VERSION * 100000) + (VARIANT_MINOR_VERSION * 100) + \
+ (VARIANT_PATCH_VERSION)
-namespace mapbox {
-namespace util {
+namespace mapbox
+{
+namespace util
+{
// XXX This should derive from std::logic_error instead of std::runtime_error.
// See https://github.com/mapbox/variant/issues/48 for details.
class bad_variant_access : public std::runtime_error
{
-public:
- explicit bad_variant_access(const std::string& what_arg)
- : runtime_error(what_arg) {}
+ public:
+ explicit bad_variant_access(const std::string& what_arg) :
+ runtime_error(what_arg)
+ {
+ }
- explicit bad_variant_access(const char* what_arg)
- : runtime_error(what_arg) {}
+ explicit bad_variant_access(const char* what_arg) : runtime_error(what_arg)
+ {
+ }
}; // class bad_variant_access
-template <typename R = void>
-struct MAPBOX_VARIANT_DEPRECATED static_visitor
+template <typename R = void> struct MAPBOX_VARIANT_DEPRECATED static_visitor
{
using result_type = R;
-protected:
- static_visitor() {}
- ~static_visitor() {}
+ protected:
+ static_visitor()
+ {
+ }
+ ~static_visitor()
+ {
+ }
};
-namespace detail {
+namespace detail
+{
static constexpr std::size_t invalid_value = std::size_t(-1);
-template <typename T, typename... Types>
-struct direct_type;
+template <typename T, typename... Types> struct direct_type;
template <typename T, typename First, typename... Types>
struct direct_type<T, First, Types...>
{
static constexpr std::size_t index = std::is_same<T, First>::value
- ? sizeof...(Types)
- : direct_type<T, Types...>::index;
+ ? sizeof...(Types)
+ : direct_type<T, Types...>::index;
};
-template <typename T>
-struct direct_type<T>
+template <typename T> struct direct_type<T>
{
static constexpr std::size_t index = invalid_value;
};
@@ -109,51 +118,63 @@
#else
-template <typename...>
-struct disjunction : std::false_type {};
+template <typename...> struct disjunction : std::false_type
+{
+};
-template <typename B1>
-struct disjunction<B1> : B1 {};
+template <typename B1> struct disjunction<B1> : B1
+{
+};
template <typename B1, typename B2>
-struct disjunction<B1, B2> : std::conditional<B1::value, B1, B2>::type {};
+struct disjunction<B1, B2> : std::conditional<B1::value, B1, B2>::type
+{
+};
template <typename B1, typename... Bs>
-struct disjunction<B1, Bs...> : std::conditional<B1::value, B1, disjunction<Bs...>>::type {};
+struct disjunction<B1, Bs...>
+ : std::conditional<B1::value, B1, disjunction<Bs...>>::type
+{
+};
#endif
-template <typename T, typename... Types>
-struct convertible_type;
+template <typename T, typename... Types> struct convertible_type;
template <typename T, typename First, typename... Types>
struct convertible_type<T, First, Types...>
{
- static constexpr std::size_t index = std::is_convertible<T, First>::value
- ? disjunction<std::is_convertible<T, Types>...>::value ? invalid_value : sizeof...(Types)
- : convertible_type<T, Types...>::index;
+ static constexpr std::size_t index =
+ std::is_convertible<T, First>::value
+ ? disjunction<std::is_convertible<T, Types>...>::value
+ ? invalid_value
+ : sizeof...(Types)
+ : convertible_type<T, Types...>::index;
};
-template <typename T>
-struct convertible_type<T>
+template <typename T> struct convertible_type<T>
{
static constexpr std::size_t index = invalid_value;
};
-template <typename T, typename... Types>
-struct value_traits
+template <typename T, typename... Types> struct value_traits
{
- using value_type = typename std::remove_const<typename std::remove_reference<T>::type>::type;
- static constexpr std::size_t direct_index = direct_type<value_type, Types...>::index;
+ using value_type = typename std::remove_const<
+ typename std::remove_reference<T>::type>::type;
+ static constexpr std::size_t direct_index =
+ direct_type<value_type, Types...>::index;
static constexpr bool is_direct = direct_index != invalid_value;
- static constexpr std::size_t index = is_direct ? direct_index : convertible_type<value_type, Types...>::index;
+ static constexpr std::size_t index =
+ is_direct ? direct_index
+ : convertible_type<value_type, Types...>::index;
static constexpr bool is_valid = index != invalid_value;
- static constexpr std::size_t tindex = is_valid ? sizeof...(Types)-index : 0;
- using target_type = typename std::tuple_element<tindex, std::tuple<void, Types...>>::type;
+ static constexpr std::size_t tindex =
+ is_valid ? sizeof...(Types) - index : 0;
+ using target_type =
+ typename std::tuple_element<tindex, std::tuple<void, Types...>>::type;
};
-template <typename T, typename R = void>
-struct enable_if_type
+template <typename T, typename R = void> struct enable_if_type
{
using type = R;
};
@@ -165,7 +186,8 @@
};
template <typename F, typename V>
-struct result_of_unary_visit<F, V, typename enable_if_type<typename F::result_type>::type>
+struct result_of_unary_visit<
+ F, V, typename enable_if_type<typename F::result_type>::type>
{
using type = typename F::result_type;
};
@@ -177,16 +199,15 @@
};
template <typename F, typename V>
-struct result_of_binary_visit<F, V, typename enable_if_type<typename F::result_type>::type>
+struct result_of_binary_visit<
+ F, V, typename enable_if_type<typename F::result_type>::type>
{
using type = typename F::result_type;
};
-template <std::size_t arg1, std::size_t... others>
-struct static_max;
+template <std::size_t arg1, std::size_t... others> struct static_max;
-template <std::size_t arg>
-struct static_max<arg>
+template <std::size_t arg> struct static_max<arg>
{
static const std::size_t value = arg;
};
@@ -194,14 +215,14 @@
template <std::size_t arg1, std::size_t arg2, std::size_t... others>
struct static_max<arg1, arg2, others...>
{
- static const std::size_t value = arg1 >= arg2 ? static_max<arg1, others...>::value : static_max<arg2, others...>::value;
+ static const std::size_t value = arg1 >= arg2
+ ? static_max<arg1, others...>::value
+ : static_max<arg2, others...>::value;
};
-template <typename... Types>
-struct variant_helper;
+template <typename... Types> struct variant_helper;
-template <typename T, typename... Types>
-struct variant_helper<T, Types...>
+template <typename T, typename... Types> struct variant_helper<T, Types...>
{
VARIANT_INLINE static void destroy(const std::size_t type_index, void* data)
{
@@ -215,7 +236,8 @@
}
}
- VARIANT_INLINE static void move(const std::size_t old_type_index, void* old_value, void* new_value)
+ VARIANT_INLINE static void move(const std::size_t old_type_index,
+ void* old_value, void* new_value)
{
if (old_type_index == sizeof...(Types))
{
@@ -223,11 +245,13 @@
}
else
{
- variant_helper<Types...>::move(old_type_index, old_value, new_value);
+ variant_helper<Types...>::move(old_type_index, old_value,
+ new_value);
}
}
- VARIANT_INLINE static void copy(const std::size_t old_type_index, const void* old_value, void* new_value)
+ VARIANT_INLINE static void copy(const std::size_t old_type_index,
+ const void* old_value, void* new_value)
{
if (old_type_index == sizeof...(Types))
{
@@ -235,51 +259,60 @@
}
else
{
- variant_helper<Types...>::copy(old_type_index, old_value, new_value);
+ variant_helper<Types...>::copy(old_type_index, old_value,
+ new_value);
}
}
};
-template <>
-struct variant_helper<>
+template <> struct variant_helper<>
{
- VARIANT_INLINE static void destroy(const std::size_t, void*) {}
- VARIANT_INLINE static void move(const std::size_t, void*, void*) {}
- VARIANT_INLINE static void copy(const std::size_t, const void*, void*) {}
+ VARIANT_INLINE static void destroy(const std::size_t, void*)
+ {
+ }
+ VARIANT_INLINE static void move(const std::size_t, void*, void*)
+ {
+ }
+ VARIANT_INLINE static void copy(const std::size_t, const void*, void*)
+ {
+ }
};
-template <typename T>
-struct unwrapper
+template <typename T> struct unwrapper
{
- static T const& apply_const(T const& obj) { return obj; }
- static T& apply(T& obj) { return obj; }
+ static T const& apply_const(T const& obj)
+ {
+ return obj;
+ }
+ static T& apply(T& obj)
+ {
+ return obj;
+ }
};
-template <typename T>
-struct unwrapper<recursive_wrapper<T>>
+template <typename T> struct unwrapper<recursive_wrapper<T>>
{
- static auto apply_const(recursive_wrapper<T> const& obj)
- -> typename recursive_wrapper<T>::type const&
+ static auto apply_const(recursive_wrapper<T> const& obj) ->
+ typename recursive_wrapper<T>::type const&
{
return obj.get();
}
- static auto apply(recursive_wrapper<T>& obj)
- -> typename recursive_wrapper<T>::type&
+ static auto apply(recursive_wrapper<T>& obj) ->
+ typename recursive_wrapper<T>::type&
{
return obj.get();
}
};
-template <typename T>
-struct unwrapper<std::reference_wrapper<T>>
+template <typename T> struct unwrapper<std::reference_wrapper<T>>
{
- static auto apply_const(std::reference_wrapper<T> const& obj)
- -> typename std::reference_wrapper<T>::type const&
+ static auto apply_const(std::reference_wrapper<T> const& obj) ->
+ typename std::reference_wrapper<T>::type const&
{
return obj.get();
}
- static auto apply(std::reference_wrapper<T>& obj)
- -> typename std::reference_wrapper<T>::type&
+ static auto apply(std::reference_wrapper<T>& obj) ->
+ typename std::reference_wrapper<T>::type&
{
return obj.get();
}
@@ -299,7 +332,8 @@
}
else
{
- return dispatcher<F, V, R, Types...>::apply_const(v, std::forward<F>(f));
+ return dispatcher<F, V, R, Types...>::apply_const(
+ v, std::forward<F>(f));
}
}
@@ -333,19 +367,22 @@
template <typename F, typename V, typename R, typename T, typename... Types>
struct binary_dispatcher_rhs;
-template <typename F, typename V, typename R, typename T0, typename T1, typename... Types>
+template <typename F, typename V, typename R, typename T0, typename T1,
+ typename... Types>
struct binary_dispatcher_rhs<F, V, R, T0, T1, Types...>
{
VARIANT_INLINE static R apply_const(V const& lhs, V const& rhs, F&& f)
{
if (rhs.template is<T1>()) // call binary functor
{
- return f(unwrapper<T0>::apply_const(lhs.template get_unchecked<T0>()),
- unwrapper<T1>::apply_const(rhs.template get_unchecked<T1>()));
+ return f(
+ unwrapper<T0>::apply_const(lhs.template get_unchecked<T0>()),
+ unwrapper<T1>::apply_const(rhs.template get_unchecked<T1>()));
}
else
{
- return binary_dispatcher_rhs<F, V, R, T0, Types...>::apply_const(lhs, rhs, std::forward<F>(f));
+ return binary_dispatcher_rhs<F, V, R, T0, Types...>::apply_const(
+ lhs, rhs, std::forward<F>(f));
}
}
@@ -358,7 +395,8 @@
}
else
{
- return binary_dispatcher_rhs<F, V, R, T0, Types...>::apply(lhs, rhs, std::forward<F>(f));
+ return binary_dispatcher_rhs<F, V, R, T0, Types...>::apply(
+ lhs, rhs, std::forward<F>(f));
}
}
};
@@ -382,19 +420,22 @@
template <typename F, typename V, typename R, typename T, typename... Types>
struct binary_dispatcher_lhs;
-template <typename F, typename V, typename R, typename T0, typename T1, typename... Types>
+template <typename F, typename V, typename R, typename T0, typename T1,
+ typename... Types>
struct binary_dispatcher_lhs<F, V, R, T0, T1, Types...>
{
VARIANT_INLINE static R apply_const(V const& lhs, V const& rhs, F&& f)
{
if (lhs.template is<T1>()) // call binary functor
{
- return f(unwrapper<T1>::apply_const(lhs.template get_unchecked<T1>()),
- unwrapper<T0>::apply_const(rhs.template get_unchecked<T0>()));
+ return f(
+ unwrapper<T1>::apply_const(lhs.template get_unchecked<T1>()),
+ unwrapper<T0>::apply_const(rhs.template get_unchecked<T0>()));
}
else
{
- return binary_dispatcher_lhs<F, V, R, T0, Types...>::apply_const(lhs, rhs, std::forward<F>(f));
+ return binary_dispatcher_lhs<F, V, R, T0, Types...>::apply_const(
+ lhs, rhs, std::forward<F>(f));
}
}
@@ -407,7 +448,8 @@
}
else
{
- return binary_dispatcher_lhs<F, V, R, T0, Types...>::apply(lhs, rhs, std::forward<F>(f));
+ return binary_dispatcher_lhs<F, V, R, T0, Types...>::apply(
+ lhs, rhs, std::forward<F>(f));
}
}
};
@@ -440,19 +482,24 @@
{
if (v1.template is<T>())
{
- return f(unwrapper<T>::apply_const(v0.template get_unchecked<T>()),
- unwrapper<T>::apply_const(v1.template get_unchecked<T>())); // call binary functor
+ return f(
+ unwrapper<T>::apply_const(v0.template get_unchecked<T>()),
+ unwrapper<T>::apply_const(
+ v1.template get_unchecked<T>())); // call binary functor
}
else
{
- return binary_dispatcher_rhs<F, V, R, T, Types...>::apply_const(v0, v1, std::forward<F>(f));
+ return binary_dispatcher_rhs<F, V, R, T, Types...>::apply_const(
+ v0, v1, std::forward<F>(f));
}
}
else if (v1.template is<T>())
{
- return binary_dispatcher_lhs<F, V, R, T, Types...>::apply_const(v0, v1, std::forward<F>(f));
+ return binary_dispatcher_lhs<F, V, R, T, Types...>::apply_const(
+ v0, v1, std::forward<F>(f));
}
- return binary_dispatcher<F, V, R, Types...>::apply_const(v0, v1, std::forward<F>(f));
+ return binary_dispatcher<F, V, R, Types...>::apply_const(
+ v0, v1, std::forward<F>(f));
}
VARIANT_INLINE static R apply(V& v0, V& v1, F&& f)
@@ -461,19 +508,24 @@
{
if (v1.template is<T>())
{
- return f(unwrapper<T>::apply(v0.template get_unchecked<T>()),
- unwrapper<T>::apply(v1.template get_unchecked<T>())); // call binary functor
+ return f(
+ unwrapper<T>::apply(v0.template get_unchecked<T>()),
+ unwrapper<T>::apply(
+ v1.template get_unchecked<T>())); // call binary functor
}
else
{
- return binary_dispatcher_rhs<F, V, R, T, Types...>::apply(v0, v1, std::forward<F>(f));
+ return binary_dispatcher_rhs<F, V, R, T, Types...>::apply(
+ v0, v1, std::forward<F>(f));
}
}
else if (v1.template is<T>())
{
- return binary_dispatcher_lhs<F, V, R, T, Types...>::apply(v0, v1, std::forward<F>(f));
+ return binary_dispatcher_lhs<F, V, R, T, Types...>::apply(
+ v0, v1, std::forward<F>(f));
}
- return binary_dispatcher<F, V, R, Types...>::apply(v0, v1, std::forward<F>(f));
+ return binary_dispatcher<F, V, R, Types...>::apply(v0, v1,
+ std::forward<F>(f));
}
};
@@ -483,21 +535,22 @@
VARIANT_INLINE static R apply_const(V const& v0, V const& v1, F&& f)
{
return f(unwrapper<T>::apply_const(v0.template get_unchecked<T>()),
- unwrapper<T>::apply_const(v1.template get_unchecked<T>())); // call binary functor
+ unwrapper<T>::apply_const(
+ v1.template get_unchecked<T>())); // call binary functor
}
VARIANT_INLINE static R apply(V& v0, V& v1, F&& f)
{
return f(unwrapper<T>::apply(v0.template get_unchecked<T>()),
- unwrapper<T>::apply(v1.template get_unchecked<T>())); // call binary functor
+ unwrapper<T>::apply(
+ v1.template get_unchecked<T>())); // call binary functor
}
};
// comparator functors
struct equal_comp
{
- template <typename T>
- bool operator()(T const& lhs, T const& rhs) const
+ template <typename T> bool operator()(T const& lhs, T const& rhs) const
{
return lhs == rhs;
}
@@ -505,29 +558,27 @@
struct less_comp
{
- template <typename T>
- bool operator()(T const& lhs, T const& rhs) const
+ template <typename T> bool operator()(T const& lhs, T const& rhs) const
{
return lhs < rhs;
}
};
-template <typename Variant, typename Comp>
-class comparer
+template <typename Variant, typename Comp> class comparer
{
-public:
- explicit comparer(Variant const& lhs) noexcept
- : lhs_(lhs) {}
+ public:
+ explicit comparer(Variant const& lhs) noexcept : lhs_(lhs)
+ {
+ }
comparer& operator=(comparer const&) = delete;
// visitor
- template <typename T>
- bool operator()(T const& rhs_content) const
+ template <typename T> bool operator()(T const& rhs_content) const
{
T const& lhs_content = lhs_.template get_unchecked<T>();
return Comp()(lhs_content, rhs_content);
}
-private:
+ private:
Variant const& lhs_;
};
@@ -537,56 +588,69 @@
{
};
-template <typename... Types>
-class variant
+template <typename... Types> class variant
{
- 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) > 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?");
-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;
+ 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;
- using first_type = typename std::tuple_element<0, std::tuple<Types...>>::type;
- using data_type = typename std::aligned_storage<data_size, data_align>::type;
+ using first_type =
+ typename std::tuple_element<0, std::tuple<Types...>>::type;
+ using data_type =
+ typename std::aligned_storage<data_size, data_align>::type;
using helper_type = detail::variant_helper<Types...>;
std::size_t type_index;
data_type data;
-public:
- VARIANT_INLINE variant() noexcept(std::is_nothrow_default_constructible<first_type>::value)
- : type_index(sizeof...(Types)-1)
+ public:
+ VARIANT_INLINE variant() noexcept(
+ std::is_nothrow_default_constructible<first_type>::value) :
+ type_index(sizeof...(Types) - 1)
{
- static_assert(std::is_default_constructible<first_type>::value, "First type in variant must be default constructible to allow default construction of variant");
+ static_assert(std::is_default_constructible<first_type>::value,
+ "First type in variant must be default constructible to "
+ "allow default construction of variant");
new (&data) first_type();
}
- VARIANT_INLINE variant(no_init) noexcept
- : type_index(detail::invalid_value) {}
+ VARIANT_INLINE variant(no_init) noexcept : type_index(detail::invalid_value)
+ {
+ }
// http://isocpp.org/blog/2012/11/universal-references-in-c11-scott-meyers
template <typename T, typename Traits = detail::value_traits<T, Types...>,
typename Enable = typename std::enable_if<Traits::is_valid>::type>
- VARIANT_INLINE variant(T&& val) noexcept(std::is_nothrow_constructible<typename Traits::target_type, T&&>::value)
- : type_index(Traits::index)
+ VARIANT_INLINE variant(T&& val) noexcept(
+ std::is_nothrow_constructible<typename Traits::target_type,
+ T&&>::value) :
+ type_index(Traits::index)
{
new (&data) typename Traits::target_type(std::forward<T>(val));
}
- VARIANT_INLINE variant(variant<Types...> const& old)
- : type_index(old.type_index)
+ VARIANT_INLINE variant(variant<Types...> const& old) :
+ type_index(old.type_index)
{
helper_type::copy(old.type_index, &old.data, &data);
}
- VARIANT_INLINE variant(variant<Types...>&& old) noexcept(std::is_nothrow_move_constructible<std::tuple<Types...>>::value)
- : type_index(old.type_index)
+ VARIANT_INLINE variant(variant<Types...>&& old) noexcept(
+ std::is_nothrow_move_constructible<std::tuple<Types...>>::value) :
+ type_index(old.type_index)
{
helper_type::move(old.type_index, &old.data, &data);
}
-private:
+ private:
VARIANT_INLINE void copy_assign(variant<Types...> const& rhs)
{
helper_type::destroy(type_index, &data);
@@ -603,7 +667,7 @@
type_index = rhs.type_index;
}
-public:
+ public:
VARIANT_INLINE variant<Types...>& operator=(variant<Types...>&& other)
{
move_assign(std::move(other));
@@ -636,17 +700,21 @@
}
template <typename T, typename std::enable_if<
- (detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
+ (detail::direct_type<T, Types...>::index !=
+ detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE bool is() const
{
return type_index == detail::direct_type<T, Types...>::index;
}
- template <typename T,typename std::enable_if<
- (detail::direct_type<recursive_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
+ template <typename T,
+ typename std::enable_if<
+ (detail::direct_type<recursive_wrapper<T>, Types...>::index !=
+ detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE bool is() const
{
- return type_index == detail::direct_type<recursive_wrapper<T>, Types...>::index;
+ return type_index ==
+ detail::direct_type<recursive_wrapper<T>, Types...>::index;
}
VARIANT_INLINE bool valid() const
@@ -665,7 +733,8 @@
// get_unchecked<T>()
template <typename T, typename std::enable_if<
- (detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
+ (detail::direct_type<T, Types...>::index !=
+ detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T& get_unchecked()
{
return *reinterpret_cast<T*>(&data);
@@ -674,7 +743,8 @@
#ifdef HAS_EXCEPTIONS
// get<T>()
template <typename T, typename std::enable_if<
- (detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
+ (detail::direct_type<T, Types...>::index !=
+ detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T& get()
{
if (type_index == detail::direct_type<T, Types...>::index)
@@ -689,7 +759,8 @@
#endif
template <typename T, typename std::enable_if<
- (detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
+ (detail::direct_type<T, Types...>::index !=
+ detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T const& get_unchecked() const
{
return *reinterpret_cast<T const*>(&data);
@@ -697,7 +768,8 @@
#ifdef HAS_EXCEPTIONS
template <typename T, typename std::enable_if<
- (detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
+ (detail::direct_type<T, Types...>::index !=
+ detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T const& get() const
{
if (type_index == detail::direct_type<T, Types...>::index)
@@ -712,8 +784,10 @@
#endif
// get_unchecked<T>() - T stored as recursive_wrapper<T>
- template <typename T, typename std::enable_if<
- (detail::direct_type<recursive_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
+ template <typename T,
+ typename std::enable_if<
+ (detail::direct_type<recursive_wrapper<T>, Types...>::index !=
+ detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T& get_unchecked()
{
return (*reinterpret_cast<recursive_wrapper<T>*>(&data)).get();
@@ -721,11 +795,14 @@
#ifdef HAS_EXCEPTIONS
// get<T>() - T stored as recursive_wrapper<T>
- template <typename T, typename std::enable_if<
- (detail::direct_type<recursive_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
+ template <typename T,
+ typename std::enable_if<
+ (detail::direct_type<recursive_wrapper<T>, Types...>::index !=
+ detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T& get()
{
- if (type_index == detail::direct_type<recursive_wrapper<T>, Types...>::index)
+ if (type_index ==
+ detail::direct_type<recursive_wrapper<T>, Types...>::index)
{
return (*reinterpret_cast<recursive_wrapper<T>*>(&data)).get();
}
@@ -736,21 +813,27 @@
}
#endif
- template <typename T, typename std::enable_if<
- (detail::direct_type<recursive_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
+ template <typename T,
+ typename std::enable_if<
+ (detail::direct_type<recursive_wrapper<T>, Types...>::index !=
+ detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T const& get_unchecked() const
{
return (*reinterpret_cast<recursive_wrapper<T> const*>(&data)).get();
}
#ifdef HAS_EXCEPTIONS
- template <typename T, typename std::enable_if<
- (detail::direct_type<recursive_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
+ template <typename T,
+ typename std::enable_if<
+ (detail::direct_type<recursive_wrapper<T>, Types...>::index !=
+ detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T const& get() const
{
- if (type_index == detail::direct_type<recursive_wrapper<T>, Types...>::index)
+ if (type_index ==
+ detail::direct_type<recursive_wrapper<T>, Types...>::index)
{
- return (*reinterpret_cast<recursive_wrapper<T> const*>(&data)).get();
+ return (*reinterpret_cast<recursive_wrapper<T> const*>(&data))
+ .get();
}
else
{
@@ -760,8 +843,11 @@
#endif
// get_unchecked<T>() - T stored as std::reference_wrapper<T>
- template <typename T, typename std::enable_if<
- (detail::direct_type<std::reference_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
+ template <
+ typename T,
+ typename std::enable_if<
+ (detail::direct_type<std::reference_wrapper<T>, Types...>::index !=
+ detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T& get_unchecked()
{
return (*reinterpret_cast<std::reference_wrapper<T>*>(&data)).get();
@@ -769,11 +855,15 @@
#ifdef HAS_EXCEPTIONS
// get<T>() - T stored as std::reference_wrapper<T>
- template <typename T, typename std::enable_if<
- (detail::direct_type<std::reference_wrapper<T>, Types...>::index != detail::invalid_value)>::type* = nullptr>
+ template <
+ typename T,
+ typename std::enable_if<
+ (detail::direct_type<std::reference_wrapper<T>, Types...>::index !=
+ detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T& get()
{
- if (type_index == detail::direct_type<std::reference_wrapper<T>, Types...>::index)
+ if (type_index ==
+ detail::direct_type<std::reference_wrapper<T>, Types...>::index)
{
return (*reinterpret_cast<std::reference_wrapper<T>*>(&data)).get();
}
@@ -784,21 +874,32 @@
}
#endif
- template <typename T, typename std::enable_if<
- (detail::direct_type<std::reference_wrapper<T const>, Types...>::index != detail::invalid_value)>::type* = nullptr>
+ template <typename T,
+ typename std::enable_if<
+ (detail::direct_type<std::reference_wrapper<T const>,
+ Types...>::index !=
+ detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T const& get_unchecked() const
{
- return (*reinterpret_cast<std::reference_wrapper<T const> const*>(&data)).get();
+ return (*reinterpret_cast<std::reference_wrapper<T const> const*>(
+ &data))
+ .get();
}
#ifdef HAS_EXCEPTIONS
- template <typename T, typename std::enable_if<
- (detail::direct_type<std::reference_wrapper<T const>, Types...>::index != detail::invalid_value)>::type* = nullptr>
+ template <typename T,
+ typename std::enable_if<
+ (detail::direct_type<std::reference_wrapper<T const>,
+ Types...>::index !=
+ detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE T const& get() const
{
- if (type_index == detail::direct_type<std::reference_wrapper<T const>, Types...>::index)
+ if (type_index == detail::direct_type<std::reference_wrapper<T const>,
+ Types...>::index)
{
- return (*reinterpret_cast<std::reference_wrapper<T const> const*>(&data)).get();
+ return (*reinterpret_cast<std::reference_wrapper<T const> const*>(
+ &data))
+ .get();
}
else
{
@@ -816,46 +917,63 @@
VARIANT_INLINE int which() const noexcept
{
- return static_cast<int>(sizeof...(Types)-type_index - 1);
+ return static_cast<int>(sizeof...(Types) - type_index - 1);
}
template <typename T, typename std::enable_if<
- (detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
+ (detail::direct_type<T, Types...>::index !=
+ detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE static constexpr int which() noexcept
{
- return static_cast<int>(sizeof...(Types)-detail::direct_type<T, Types...>::index - 1);
+ return static_cast<int>(sizeof...(Types) -
+ detail::direct_type<T, Types...>::index - 1);
}
// visitor
// unary
- template <typename F, typename V, typename R = typename detail::result_of_unary_visit<F, first_type>::type>
+ template <typename F, typename V,
+ typename R =
+ typename detail::result_of_unary_visit<F, first_type>::type>
auto VARIANT_INLINE static visit(V const& v, F&& f)
- -> decltype(detail::dispatcher<F, V, R, Types...>::apply_const(v, std::forward<F>(f)))
+ -> decltype(detail::dispatcher<F, V, R, Types...>::apply_const(
+ v, std::forward<F>(f)))
{
- return detail::dispatcher<F, V, R, Types...>::apply_const(v, std::forward<F>(f));
+ return detail::dispatcher<F, V, R, Types...>::apply_const(
+ v, std::forward<F>(f));
}
// non-const
- template <typename F, typename V, typename R = typename detail::result_of_unary_visit<F, first_type>::type>
- auto VARIANT_INLINE static visit(V& v, F&& f)
- -> decltype(detail::dispatcher<F, V, R, Types...>::apply(v, std::forward<F>(f)))
+ template <typename F, typename V,
+ typename R =
+ typename detail::result_of_unary_visit<F, first_type>::type>
+ auto VARIANT_INLINE static visit(V& v, F&& f) -> decltype(
+ detail::dispatcher<F, V, R, Types...>::apply(v, std::forward<F>(f)))
{
- return detail::dispatcher<F, V, R, Types...>::apply(v, std::forward<F>(f));
+ return detail::dispatcher<F, V, R, Types...>::apply(v,
+ std::forward<F>(f));
}
// binary
// const
- template <typename F, typename V, typename R = typename detail::result_of_binary_visit<F, first_type>::type>
+ template <typename F, typename V,
+ typename R =
+ typename detail::result_of_binary_visit<F, first_type>::type>
auto VARIANT_INLINE static binary_visit(V const& v0, V const& v1, F&& f)
- -> decltype(detail::binary_dispatcher<F, V, R, Types...>::apply_const(v0, v1, std::forward<F>(f)))
+ -> decltype(detail::binary_dispatcher<F, V, R, Types...>::apply_const(
+ v0, v1, std::forward<F>(f)))
{
- return detail::binary_dispatcher<F, V, R, Types...>::apply_const(v0, v1, std::forward<F>(f));
+ return detail::binary_dispatcher<F, V, R, Types...>::apply_const(
+ v0, v1, std::forward<F>(f));
}
// non-const
- template <typename F, typename V, typename R = typename detail::result_of_binary_visit<F, first_type>::type>
+ template <typename F, typename V,
+ typename R =
+ typename detail::result_of_binary_visit<F, first_type>::type>
auto VARIANT_INLINE static binary_visit(V& v0, V& v1, F&& f)
- -> decltype(detail::binary_dispatcher<F, V, R, Types...>::apply(v0, v1, std::forward<F>(f)))
+ -> decltype(detail::binary_dispatcher<F, V, R, Types...>::apply(
+ v0, v1, std::forward<F>(f)))
{
- return detail::binary_dispatcher<F, V, R, Types...>::apply(v0, v1, std::forward<F>(f));
+ return detail::binary_dispatcher<F, V, R, Types...>::apply(
+ v0, v1, std::forward<F>(f));
}
~variant() noexcept // no-throw destructor
@@ -909,14 +1027,16 @@
// unary visitor interface
// const
template <typename F, typename V>
-auto VARIANT_INLINE apply_visitor(F&& f, V const& v) -> decltype(V::visit(v, std::forward<F>(f)))
+auto VARIANT_INLINE apply_visitor(F&& f, V const& v)
+ -> decltype(V::visit(v, std::forward<F>(f)))
{
return V::visit(v, std::forward<F>(f));
}
// non-const
template <typename F, typename V>
-auto VARIANT_INLINE apply_visitor(F&& f, V& v) -> decltype(V::visit(v, std::forward<F>(f)))
+auto VARIANT_INLINE apply_visitor(F&& f, V& v)
+ -> decltype(V::visit(v, std::forward<F>(f)))
{
return V::visit(v, std::forward<F>(f));
}
@@ -924,37 +1044,38 @@
// binary visitor interface
// const
template <typename F, typename V>
-auto VARIANT_INLINE apply_visitor(F&& f, V const& v0, V const& v1) -> decltype(V::binary_visit(v0, v1, std::forward<F>(f)))
+auto VARIANT_INLINE apply_visitor(F&& f, V const& v0, V const& v1)
+ -> decltype(V::binary_visit(v0, v1, std::forward<F>(f)))
{
return V::binary_visit(v0, v1, std::forward<F>(f));
}
// non-const
template <typename F, typename V>
-auto VARIANT_INLINE apply_visitor(F&& f, V& v0, V& v1) -> decltype(V::binary_visit(v0, v1, std::forward<F>(f)))
+auto VARIANT_INLINE apply_visitor(F&& f, V& v0, V& v1)
+ -> decltype(V::binary_visit(v0, v1, std::forward<F>(f)))
{
return V::binary_visit(v0, v1, std::forward<F>(f));
}
-// getter interface
+ // getter interface
#ifdef HAS_EXCEPTIONS
template <typename ResultType, typename T>
-auto get(T& var)->decltype(var.template get<ResultType>())
+auto get(T& var) -> decltype(var.template get<ResultType>())
{
return var.template get<ResultType>();
}
#endif
-template <typename ResultType, typename T>
-ResultType& get_unchecked(T& var)
+template <typename ResultType, typename T> ResultType& get_unchecked(T& var)
{
return var.template get_unchecked<ResultType>();
}
#ifdef HAS_EXCEPTIONS
template <typename ResultType, typename T>
-auto get(T const& var)->decltype(var.template get<ResultType>())
+auto get(T const& var) -> decltype(var.template get<ResultType>())
{
return var.template get<ResultType>();
}