20 #ifndef CONDITIONAL_FORWARD_HPP_
21 #define CONDITIONAL_FORWARD_HPP_
23 #include <type_traits>
29 template<
typename T1,
typename T2>
30 using fwd_type =
typename std::conditional<std::is_lvalue_reference<T1>::value,
31 T2,
typename std::remove_reference<T2>::type&&>::type;
33 template<
typename T1,
typename T2>
34 fwd_type<T1, T2> conditional_forward(T2&& value) {
35 return std::forward<fwd_type<T1, T2>>(std::forward<T2>(value));
40 template<
typename Container>
41 auto forward_begin(Container&& c) ->
typename std::enable_if<
42 std::is_lvalue_reference<Container>::value ||
43 std::is_same<typename std::remove_reference<Container>::type::const_iterator, decltype(c.begin())>::value,
50 template<
typename Container>
51 auto forward_begin(Container&& c) ->
typename std::enable_if<
52 !std::is_lvalue_reference<Container>::value &&
53 !std::is_same<typename std::remove_reference<Container>::type::const_iterator, decltype(c.begin())>::value,
54 decltype(std::make_move_iterator(c.begin()))
57 return std::make_move_iterator(c.begin());
60 template<
typename Container>
61 auto forward_end(Container&& c) ->
typename std::enable_if<
62 std::is_lvalue_reference<Container>::value ||
63 std::is_same<typename std::remove_reference<Container>::type::const_iterator, decltype(c.begin())>::value,
70 template<
typename Container>
71 auto forward_end(Container&& c) ->
typename std::enable_if<
72 !std::is_lvalue_reference<Container>::value &&
73 !std::is_same<typename std::remove_reference<Container>::type::const_iterator, decltype(c.begin())>::value,
74 decltype(std::make_move_iterator(c.end()))
77 return std::make_move_iterator(c.end());
DataSketches namespace.
Definition: binomial_bounds.hpp:38