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/08 18:56:33 UTC

[datasketches-cpp] branch fix_forwarding_iterators created (now e520318)

This is an automated email from the ASF dual-hosted git repository.

alsay pushed a change to branch fix_forwarding_iterators
in repository https://gitbox.apache.org/repos/asf/datasketches-cpp.git.


      at e520318  no move if const_iterator

This branch includes the following new commits:

     new e520318  no move if const_iterator

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org


[datasketches-cpp] 01/01: no move if const_iterator

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

alsay pushed a commit to branch fix_forwarding_iterators
in repository https://gitbox.apache.org/repos/asf/datasketches-cpp.git

commit e520318457b9767301116f4378500b1277884cda
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