public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Remove redundant std::move in std::for_each
@ 2016-07-15 19:53 Jonathan Wakely
  2016-07-15 19:54 ` Daniel Krügler
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Wakely @ 2016-07-15 19:53 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 268 bytes --]

Returning a parameter will try to move anyway, so using std::move here
is redundant (and clang even warns about it being redundant).

	* include/bits/stl_algo.h (for_each): Remove redundant _GLIBCXX_MOVE
	and adjust comment.

Tested x86_64-linux, committed to trunk.


[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1319 bytes --]

commit 54ee8abfe62dc97f725843f58fe896eebcc52db0
Author: redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri Jul 15 19:51:33 2016 +0000

    Remove redundant std::move in std::for_each
    
    	* include/bits/stl_algo.h (for_each): Remove redundant _GLIBCXX_MOVE
    	and adjust comment.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@238399 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h
index a0820d4..ea0b56c 100644
--- a/libstdc++-v3/include/bits/stl_algo.h
+++ b/libstdc++-v3/include/bits/stl_algo.h
@@ -3791,7 +3791,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
    *  @param  __first  An input iterator.
    *  @param  __last   An input iterator.
    *  @param  __f      A unary function object.
-   *  @return   @p __f (std::move(@p __f) in C++0x).
+   *  @return   @p __f
    *
    *  Applies the function object @p __f to each element in the range
    *  @p [first,last).  @p __f must not modify the order of the sequence.
@@ -3806,7 +3806,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
       __glibcxx_requires_valid_range(__first, __last);
       for (; __first != __last; ++__first)
 	__f(*__first);
-      return _GLIBCXX_MOVE(__f);
+      return __f; // N.B. [alg.foreach] says std::move(f) but it's redundant.
     }
 
   /**

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Remove redundant std::move in std::for_each
  2016-07-15 19:53 [PATCH] Remove redundant std::move in std::for_each Jonathan Wakely
@ 2016-07-15 19:54 ` Daniel Krügler
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Krügler @ 2016-07-15 19:54 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches List

2016-07-15 21:53 GMT+02:00 Jonathan Wakely <jwakely@redhat.com>:
> Returning a parameter will try to move anyway, so using std::move here
> is redundant (and clang even warns about it being redundant).
>
>         * include/bits/stl_algo.h (for_each): Remove redundant _GLIBCXX_MOVE
>         and adjust comment.

Actually I think this should also be reported as an LWG issue.

- Daniel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-15 19:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-15 19:53 [PATCH] Remove redundant std::move in std::for_each Jonathan Wakely
2016-07-15 19:54 ` Daniel Krügler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).