2
0
mirror of https://github.com/boostorg/variant.git synced 2026-01-19 04:42:16 +00:00

change typename template parameter to bool

This commit is contained in:
diplay
2017-10-17 11:43:44 +03:00
parent 28f8707515
commit f87445832e
5 changed files with 60 additions and 71 deletions

View File

@@ -31,9 +31,6 @@
#endif
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
# define USE_UNIVERSAL_REF
# include <boost/mpl/logical.hpp>
# include <boost/type_traits/is_same.hpp>
# include <boost/move/move.hpp>
# include <boost/move/utility.hpp>
@@ -51,7 +48,7 @@ namespace boost {
namespace detail { namespace variant {
template <typename Visitor, typename Value1, typename MoveSemantics>
template <typename Visitor, typename Value1, bool MoveSemantics>
class apply_visitor_binary_invoke
{
public: // visitor typedefs
@@ -74,17 +71,17 @@ public: // structors
public: // visitor interfaces
#ifdef USE_UNIVERSAL_REF
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <typename Value2>
typename enable_if<mpl::and_<MoveSemantics, is_same<Value2, Value2>>, BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)>::type
typename enable_if_c<MoveSemantics && is_same<Value2, Value2>::value, BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)>::type
operator()(Value2&& value2)
{
return visitor_(::boost::move(value1_), ::boost::forward<Value2>(value2));
}
template <typename Value2>
typename disable_if<mpl::and_<MoveSemantics, is_same<Value2, Value2>>, BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)>::type
typename disable_if_c<MoveSemantics && is_same<Value2, Value2>::value, BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)>::type
operator()(Value2&& value2)
{
return visitor_(value1_, ::boost::forward<Value2>(value2));
@@ -105,7 +102,7 @@ private:
apply_visitor_binary_invoke& operator=(const apply_visitor_binary_invoke&);
};
template <typename Visitor, typename Visitable2, typename MoveSemantics>
template <typename Visitor, typename Visitable2, bool MoveSemantics>
class apply_visitor_binary_unwrap
{
public: // visitor typedefs
@@ -128,29 +125,29 @@ public: // structors
public: // visitor interfaces
#ifdef USE_UNIVERSAL_REF
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <typename Value1>
typename enable_if<mpl::and_<MoveSemantics, is_same<Value1, Value1>>, BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)>::type
typename enable_if_c<MoveSemantics && is_same<Value1, Value1>::value, BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)>::type
operator()(Value1&& value1)
{
apply_visitor_binary_invoke<
Visitor
, Value1
, mpl::not_<::boost::is_lvalue_reference<Value1>>
, ! ::boost::is_lvalue_reference<Value1>::value
> invoker(visitor_, value1);
return boost::apply_visitor(invoker, ::boost::move(visitable2_));
}
template <typename Value1>
typename disable_if<mpl::and_<MoveSemantics, is_same<Value1, Value1>>, BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)>::type
typename disable_if_c<MoveSemantics && is_same<Value1, Value1>::value, BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)>::type
operator()(Value1&& value1)
{
apply_visitor_binary_invoke<
Visitor
, Value1
, mpl::not_<::boost::is_lvalue_reference<Value1>>
, ! ::boost::is_lvalue_reference<Value1>::value
> invoker(visitor_, value1);
return boost::apply_visitor(invoker, visitable2_);
@@ -165,7 +162,7 @@ public: // visitor interfaces
apply_visitor_binary_invoke<
Visitor
, Value1
, ::boost::false_type
, false
> invoker(visitor_, value1);
return boost::apply_visitor(invoker, visitable2_);
@@ -201,7 +198,7 @@ private:
#endif // EDG-based compilers workaround
#ifdef USE_UNIVERSAL_REF
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <typename Visitor, typename Visitable1, typename Visitable2>
inline
@@ -209,7 +206,7 @@ inline
apply_visitor( Visitor& visitor, Visitable1&& visitable1, Visitable2&& visitable2)
{
::boost::detail::variant::apply_visitor_binary_unwrap<
Visitor, Visitable2, mpl::not_<::boost::is_lvalue_reference<Visitable2>>
Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
> unwrapper(visitor, visitable2);
return boost::apply_visitor(unwrapper, ::boost::forward<Visitable1>(visitable1));
@@ -223,7 +220,7 @@ inline
apply_visitor( Visitor& visitor, Visitable1& visitable1, Visitable2& visitable2)
{
::boost::detail::variant::apply_visitor_binary_unwrap<
Visitor, Visitable2, ::boost::false_type
Visitor, Visitable2, false
> unwrapper(visitor, visitable2);
return boost::apply_visitor(unwrapper, visitable1);
@@ -237,7 +234,7 @@ apply_visitor( Visitor& visitor, Visitable1& visitable1, Visitable2& visitable2)
// const-visitor version:
//
#ifdef USE_UNIVERSAL_REF
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <typename Visitor, typename Visitable1, typename Visitable2>
inline
@@ -247,7 +244,7 @@ inline
apply_visitor( const Visitor& visitor , Visitable1&& visitable1 , Visitable2&& visitable2)
{
::boost::detail::variant::apply_visitor_binary_unwrap<
const Visitor, Visitable2, mpl::not_<::boost::is_lvalue_reference<Visitable2>>
const Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
> unwrapper(visitor, visitable2);
return boost::apply_visitor(unwrapper, ::boost::forward<Visitable1>(visitable1));
@@ -263,7 +260,7 @@ inline
apply_visitor( const Visitor& visitor , Visitable1& visitable1 , Visitable2& visitable2)
{
::boost::detail::variant::apply_visitor_binary_unwrap<
const Visitor, Visitable2, ::boost::false_type
const Visitor, Visitable2, false
> unwrapper(visitor, visitable2);
return boost::apply_visitor(unwrapper, visitable1);
@@ -282,7 +279,7 @@ apply_visitor( const Visitor& visitor , Visitable1& visitable1 , Visitable2& vis
namespace detail { namespace variant {
template <typename Visitor, typename Value1, typename MoveSemantics>
template <typename Visitor, typename Value1, bool MoveSemantics>
class apply_visitor_binary_invoke_cpp14
{
Visitor& visitor_;
@@ -299,13 +296,13 @@ public: // structors
public: // visitor interfaces
template <typename Value2>
decltype(auto) operator()(Value2&& value2, typename enable_if<mpl::and_<MoveSemantics, is_same<Value2, Value2>>>::type* = 0)
decltype(auto) operator()(Value2&& value2, typename enable_if_c<MoveSemantics && is_same<Value2, Value2>::value>::type* = 0)
{
return visitor_(::boost::move(value1_), ::boost::forward<Value2>(value2));
}
template <typename Value2>
decltype(auto) operator()(Value2&& value2, typename disable_if<mpl::and_<MoveSemantics, is_same<Value2, Value2>>>::type* = 0)
decltype(auto) operator()(Value2&& value2, typename disable_if_c<MoveSemantics && is_same<Value2, Value2>::value>::type* = 0)
{
return visitor_(value1_, ::boost::forward<Value2>(value2));
}
@@ -314,7 +311,7 @@ private:
apply_visitor_binary_invoke_cpp14& operator=(const apply_visitor_binary_invoke_cpp14&);
};
template <typename Visitor, typename Visitable2, typename MoveSemantics>
template <typename Visitor, typename Visitable2, bool MoveSemantics>
class apply_visitor_binary_unwrap_cpp14
{
Visitor& visitor_;
@@ -331,24 +328,24 @@ public: // structors
public: // visitor interfaces
template <typename Value1>
decltype(auto) operator()(Value1&& value1, typename enable_if<mpl::and_<MoveSemantics, is_same<Value1, Value1>>>::type* = 0)
decltype(auto) operator()(Value1&& value1, typename enable_if_c<MoveSemantics && is_same<Value1, Value1>::value>::type* = 0)
{
apply_visitor_binary_invoke_cpp14<
Visitor
, Value1
, mpl::not_<::boost::is_lvalue_reference<Value1>>
, ! ::boost::is_lvalue_reference<Value1>::value
> invoker(visitor_, value1);
return boost::apply_visitor(invoker, ::boost::move(visitable2_));
}
template <typename Value1>
decltype(auto) operator()(Value1&& value1, typename disable_if<mpl::and_<MoveSemantics, is_same<Value1, Value1>>>::type* = 0)
decltype(auto) operator()(Value1&& value1, typename disable_if_c<MoveSemantics && is_same<Value1, Value1>::value>::type* = 0)
{
apply_visitor_binary_invoke_cpp14<
Visitor
, Value1
, mpl::not_<::boost::is_lvalue_reference<Value1>>
, ! ::boost::is_lvalue_reference<Value1>::value
> invoker(visitor_, value1);
return boost::apply_visitor(invoker, visitable2_);
@@ -367,7 +364,7 @@ inline decltype(auto) apply_visitor(Visitor& visitor, Visitable1&& visitable1, V
>::type* = 0)
{
::boost::detail::variant::apply_visitor_binary_unwrap_cpp14<
Visitor, Visitable2, mpl::not_<::boost::is_lvalue_reference<Visitable2>>
Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
> unwrapper(visitor, visitable2);
return boost::apply_visitor(unwrapper, ::boost::forward<Visitable1>(visitable1));
@@ -380,7 +377,7 @@ inline decltype(auto) apply_visitor(const Visitor& visitor, Visitable1&& visitab
>::type* = 0)
{
::boost::detail::variant::apply_visitor_binary_unwrap_cpp14<
const Visitor, Visitable2, mpl::not_<::boost::is_lvalue_reference<Visitable2>>
const Visitor, Visitable2, ! ::boost::is_lvalue_reference<Visitable2>::value
> unwrapper(visitor, visitable2);
return boost::apply_visitor(unwrapper, ::boost::forward<Visitable1>(visitable1));
@@ -391,6 +388,4 @@ inline decltype(auto) apply_visitor(const Visitor& visitor, Visitable1&& visitab
} // namespace boost
#undef USE_UNIVERSAL_REF
#endif // BOOST_VARIANT_DETAIL_APPLY_VISITOR_BINARY_HPP

View File

@@ -65,10 +65,6 @@ namespace boost {
#endif // EDG-based compilers workaround
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
# define USE_UNIVERSAL_REF
#endif
#ifdef USE_UNIVERSAL_REF
template <typename Visitor, typename Visitable>
inline
BOOST_VARIANT_AUX_APPLY_VISITOR_NON_CONST_RESULT_TYPE(Visitor)
@@ -92,7 +88,7 @@ apply_visitor(Visitor& visitor, Visitable& visitable)
// const-visitor version:
//
#ifdef USE_UNIVERSAL_REF
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <typename Visitor, typename Visitable>
inline
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(typename Visitor::result_type)
@@ -110,8 +106,6 @@ apply_visitor(const Visitor& visitor, Visitable& visitable)
}
#endif
#undef USE_UNIVERSAL_REF
#if !defined(BOOST_NO_CXX14_DECLTYPE_AUTO) && !defined(BOOST_NO_CXX11_DECLTYPE_N3276)

View File

@@ -44,16 +44,16 @@ namespace detail { namespace variant {
: index_sequence<I...>
{};
template <typename T_, typename MoveSemantics_>
template <typename T_, bool MoveSemantics_>
struct MoveableWrapper //Just a reference with some metadata
{
typedef T_ T;
typedef MoveSemantics_ MoveSemantics;
static constexpr bool MoveSemantics = MoveSemantics_;
T& v;
};
template <typename Tp, typename MoveSemantics>
template <typename Tp, bool MoveSemantics>
MoveableWrapper<Tp, MoveSemantics>
wrap(Tp& t)
{
@@ -61,14 +61,14 @@ namespace detail { namespace variant {
}
template <typename Wrapper>
typename enable_if<typename Wrapper::MoveSemantics, typename Wrapper::T>::type
typename enable_if_c<Wrapper::MoveSemantics, typename Wrapper::T>::type
unwrap(Wrapper& w)
{
return ::boost::move(w.v);
}
template <typename Wrapper>
typename disable_if<typename Wrapper::MoveSemantics, typename Wrapper::T>::type &
typename disable_if_c<Wrapper::MoveSemantics, typename Wrapper::T>::type &
unwrap(Wrapper& w)
{
return w.v;
@@ -132,7 +132,7 @@ namespace detail { namespace variant {
make_one_by_one_visitor_and_value_referer(
visitor_,
tuple_tail(visitables_),
std::tuple_cat(values_, std::make_tuple(wrap<Value, mpl::not_<::boost::is_lvalue_reference<Value>>>(value)))
std::tuple_cat(values_, std::make_tuple(wrap<Value, ! ::boost::is_lvalue_reference<Value>::value>(value)))
)
, unwrap(std::get<0>(visitables_)) // getting Head element
);
@@ -167,7 +167,7 @@ namespace detail { namespace variant {
BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type) operator()(Value&& value) const
{
return do_call(
std::tuple_cat(values_, std::make_tuple(wrap<Value, mpl::not_<::boost::is_lvalue_reference<Value>>>(value))),
std::tuple_cat(values_, std::make_tuple(wrap<Value, ! ::boost::is_lvalue_reference<Value>::value>(value))),
make_index_sequence<sizeof...(Values) + 1>()
);
}
@@ -183,9 +183,9 @@ namespace detail { namespace variant {
::boost::detail::variant::make_one_by_one_visitor_and_value_referer(
visitor,
std::make_tuple(
::boost::detail::variant::wrap<T2, mpl::not_<::boost::is_lvalue_reference<T2>>>(v2),
::boost::detail::variant::wrap<T3, mpl::not_<::boost::is_lvalue_reference<T3>>>(v3),
::boost::detail::variant::wrap<TN, mpl::not_<::boost::is_lvalue_reference<TN>>>(vn)...
::boost::detail::variant::wrap<T2, ! ::boost::is_lvalue_reference<T2>::value>(v2),
::boost::detail::variant::wrap<T3, ! ::boost::is_lvalue_reference<T3>::value>(v3),
::boost::detail::variant::wrap<TN, ! ::boost::is_lvalue_reference<TN>::value>(vn)...
),
std::tuple<>()
),
@@ -201,9 +201,9 @@ namespace detail { namespace variant {
::boost::detail::variant::make_one_by_one_visitor_and_value_referer(
visitor,
std::make_tuple(
::boost::detail::variant::wrap<T2, mpl::not_<::boost::is_lvalue_reference<T2>>>(v2),
::boost::detail::variant::wrap<T3, mpl::not_<::boost::is_lvalue_reference<T3>>>(v3),
::boost::detail::variant::wrap<TN, mpl::not_<::boost::is_lvalue_reference<TN>>>(vn)...
::boost::detail::variant::wrap<T2, ! ::boost::is_lvalue_reference<T2>::value>(v2),
::boost::detail::variant::wrap<T3, ! ::boost::is_lvalue_reference<T3>::value>(v3),
::boost::detail::variant::wrap<TN, ! ::boost::is_lvalue_reference<TN>::value>(vn)...
),
std::tuple<>()
),

View File

@@ -62,7 +62,7 @@ namespace detail { namespace variant {
make_one_by_one_visitor_and_value_referer_cpp14(
visitor_,
tuple_tail(visitables_),
std::tuple_cat(values_, std::make_tuple(wrap<Value, mpl::not_<::boost::is_lvalue_reference<Value>>>(value)))
std::tuple_cat(values_, std::make_tuple(wrap<Value, ! ::boost::is_lvalue_reference<Value>::value>(value)))
)
, unwrap(std::get<0>(visitables_)) // getting Head element
);
@@ -95,7 +95,7 @@ namespace detail { namespace variant {
decltype(auto) operator()(Value&& value) const
{
return do_call(
std::tuple_cat(values_, std::make_tuple(wrap<Value, mpl::not_<::boost::is_lvalue_reference<Value>>>(value))),
std::tuple_cat(values_, std::make_tuple(wrap<Value, ! ::boost::is_lvalue_reference<Value>::value>(value))),
make_index_sequence<sizeof...(Values) + 1>()
);
}
@@ -113,9 +113,9 @@ namespace detail { namespace variant {
::boost::detail::variant::make_one_by_one_visitor_and_value_referer_cpp14(
visitor,
std::make_tuple(
::boost::detail::variant::wrap<T2, mpl::not_<::boost::is_lvalue_reference<T2>>>(v2),
::boost::detail::variant::wrap<T3, mpl::not_<::boost::is_lvalue_reference<T3>>>(v3),
::boost::detail::variant::wrap<TN, mpl::not_<::boost::is_lvalue_reference<TN>>>(vn)...
::boost::detail::variant::wrap<T2, ! ::boost::is_lvalue_reference<T2>::value>(v2),
::boost::detail::variant::wrap<T3, ! ::boost::is_lvalue_reference<T3>::value>(v3),
::boost::detail::variant::wrap<TN, ! ::boost::is_lvalue_reference<TN>::value>(vn)...
),
std::tuple<>()
),
@@ -134,9 +134,9 @@ namespace detail { namespace variant {
::boost::detail::variant::make_one_by_one_visitor_and_value_referer_cpp14(
visitor,
std::make_tuple(
::boost::detail::variant::wrap<T2, mpl::not_<::boost::is_lvalue_reference<T2>>>(v2),
::boost::detail::variant::wrap<T3, mpl::not_<::boost::is_lvalue_reference<T3>>>(v3),
::boost::detail::variant::wrap<TN, mpl::not_<::boost::is_lvalue_reference<TN>>>(vn)...
::boost::detail::variant::wrap<T2, ! ::boost::is_lvalue_reference<T2>::value>(v2),
::boost::detail::variant::wrap<T3, ! ::boost::is_lvalue_reference<T3>::value>(v3),
::boost::detail::variant::wrap<TN, ! ::boost::is_lvalue_reference<TN>::value>(vn)...
),
std::tuple<>()
),

View File

@@ -1019,7 +1019,7 @@ struct less_comp
// * for wrappers (e.g., recursive_wrapper), the wrapper's held value.
// * for all other values, the value itself.
//
template <typename Visitor, typename MoveSemantics>
template <typename Visitor, bool MoveSemantics>
class invoke_visitor
{
private: // representation
@@ -1046,14 +1046,14 @@ public: // internal visitor interfaces
//using workaround with is_same<T, T> to prenvent compilation error, because we need to use T in enable_if to make SFINAE work
template <typename T>
typename enable_if<mpl::and_<MoveSemantics, is_same<T, T>>, result_type>::type internal_visit(T&& operand, int)
typename enable_if_c<MoveSemantics && is_same<T, T>::value, result_type>::type internal_visit(T&& operand, int)
{
return visitor_(::boost::move<T>(operand));
}
//using workaround with is_same<T, T> to prenvent compilation error, because we need to use T in enable_if to make SFINAE work
template <typename T>
typename disable_if<mpl::and_<MoveSemantics, is_same<T, T>>, result_type>::type internal_visit(T&& operand, int)
typename disable_if_c<MoveSemantics && is_same<T, T>::value, result_type>::type internal_visit(T&& operand, int)
{
return visitor_(operand);
}
@@ -1084,7 +1084,7 @@ private: // helpers, for internal visitor interfaces (below)
//using workaround with is_same<T, T> to prenvent compilation error, because we need to use T in enable_if to make SFINAE work
template <typename T>
typename enable_if<mpl::and_<MoveSemantics, is_same<T, T>>, BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)>::type
typename enable_if<mpl::and_<MoveSemantics && is_same<T, T>::value>, BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)>::type
visit_impl(T&& operand, mpl::false_)
{
return visitor_(::boost::move(operand));
@@ -1092,7 +1092,7 @@ private: // helpers, for internal visitor interfaces (below)
//using workaround with is_same<T, T> to prenvent compilation error, because we need to use T in enable_if to make SFINAE work
template <typename T>
typename enable_if<mpl::and_<MoveSemantics, is_same<T, T>>, BOOST_VARIANT_AUX_RETURN_VOID_TYPE>::type
typename enable_if_c<MoveSemantics && is_same<T, T>::value, BOOST_VARIANT_AUX_RETURN_VOID_TYPE>::type
visit_impl(T&& operand, mpl::true_)
{
visitor_(::boost::move(operand));
@@ -1101,7 +1101,7 @@ private: // helpers, for internal visitor interfaces (below)
//using workaround with is_same<T, T> to prenvent compilation error, because we need to use T in enable_if to make SFINAE work
template <typename T>
typename disable_if<mpl::and_<MoveSemantics, is_same<T, T>>, BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)>::type
typename disable_if_c<MoveSemantics && is_same<T, T>::value, BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(result_type)>::type
visit_impl(T&& operand, mpl::false_)
{
return visitor_(operand);
@@ -1109,7 +1109,7 @@ private: // helpers, for internal visitor interfaces (below)
//using workaround with is_same<T, T> to prenvent compilation error, because we need to use T in enable_if to make SFINAE work
template <typename T>
typename disable_if<mpl::and_<MoveSemantics, is_same<T, T>>, BOOST_VARIANT_AUX_RETURN_VOID_TYPE>::type
typename disable_if<MoveSemantics && is_same<T, T>::value, BOOST_VARIANT_AUX_RETURN_VOID_TYPE>::type
visit_impl(T&& operand, mpl::true_)
{
visitor_(operand);
@@ -2489,7 +2489,7 @@ public: // visitation support
)
apply_visitor(Visitor& visitor) &&
{
detail::variant::invoke_visitor<Visitor, ::boost::true_type> invoker(visitor);
detail::variant::invoke_visitor<Visitor, true> invoker(visitor);
return this->internal_apply_visitor(invoker);
}
@@ -2499,7 +2499,7 @@ public: // visitation support
)
apply_visitor(Visitor& visitor) const&&
{
detail::variant::invoke_visitor<Visitor, ::boost::true_type> invoker(visitor);
detail::variant::invoke_visitor<Visitor, true> invoker(visitor);
return this->internal_apply_visitor(invoker);
}
@@ -2514,7 +2514,7 @@ public: // visitation support
&
#endif
{
detail::variant::invoke_visitor<Visitor, ::boost::false_type> invoker(visitor);
detail::variant::invoke_visitor<Visitor, false> invoker(visitor);
return this->internal_apply_visitor(invoker);
}
@@ -2527,7 +2527,7 @@ public: // visitation support
&
#endif
{
detail::variant::invoke_visitor<Visitor, ::boost::false_type> invoker(visitor);
detail::variant::invoke_visitor<Visitor, false> invoker(visitor);
return this->internal_apply_visitor(invoker);
}