You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by al...@apache.org on 2021/07/09 21:50:49 UTC
[datasketches-cpp] branch 3.1.x updated: no move if const_iterator
This is an automated email from the ASF dual-hosted git repository.
alsay pushed a commit to branch 3.1.x
in repository https://gitbox.apache.org/repos/asf/datasketches-cpp.git
The following commit(s) were added to refs/heads/3.1.x by this push:
new a375f98 no move if const_iterator
a375f98 is described below
commit a375f9805ab8064b20e6a1b82282e4d04b102328
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Thu Jul 8 11:55:57 2021 -0700
no move if const_iterator
---
common/include/conditional_forward.hpp | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/common/include/conditional_forward.hpp b/common/include/conditional_forward.hpp
index 4648b85..71ade84 100644
--- a/common/include/conditional_forward.hpp
+++ b/common/include/conditional_forward.hpp
@@ -38,29 +38,41 @@ fwd_type<T1, T2> conditional_forward(T2&& value) {
// Forward container as iterators
template<typename Container>
-auto forward_begin(Container&& c) ->
-typename std::enable_if<std::is_lvalue_reference<Container>::value, decltype(c.begin())>::type
+auto forward_begin(Container&& c) -> typename std::enable_if<
+ std::is_lvalue_reference<Container>::value ||
+ std::is_same<typename std::remove_reference<Container>::type::const_iterator, decltype(c.begin())>::value,
+ decltype(c.begin())
+>::type
{
return c.begin();
}
template<typename Container>
-auto forward_begin(Container&& c) ->
-typename std::enable_if<!std::is_lvalue_reference<Container>::value, decltype(std::make_move_iterator(c.begin()))>::type
+auto forward_begin(Container&& c) -> typename std::enable_if<
+ !std::is_lvalue_reference<Container>::value &&
+ !std::is_same<typename std::remove_reference<Container>::type::const_iterator, decltype(c.begin())>::value,
+ decltype(std::make_move_iterator(c.begin()))
+>::type
{
return std::make_move_iterator(c.begin());
}
template<typename Container>
-auto forward_end(Container&& c) ->
-typename std::enable_if<std::is_lvalue_reference<Container>::value, decltype(c.end())>::type
+auto forward_end(Container&& c) -> typename std::enable_if<
+ std::is_lvalue_reference<Container>::value ||
+ std::is_same<typename std::remove_reference<Container>::type::const_iterator, decltype(c.begin())>::value,
+ decltype(c.end())
+>::type
{
return c.end();
}
template<typename Container>
-auto forward_end(Container&& c) ->
-typename std::enable_if<!std::is_lvalue_reference<Container>::value, decltype(std::make_move_iterator(c.end()))>::type
+auto forward_end(Container&& c) -> typename std::enable_if<
+ !std::is_lvalue_reference<Container>::value &&
+ !std::is_same<typename std::remove_reference<Container>::type::const_iterator, decltype(c.begin())>::value,
+ decltype(std::make_move_iterator(c.end()))
+>::type
{
return std::make_move_iterator(c.end());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org