Commit 94f7d7ec by Jonathan Wakely

libstdc++: Fix comment on __memcpyable

The discussion of iterator_traits<volatile T*>::value_type and  the
example with three tempalte arguments related to an earlier version of
the patch, not the one committed.

Also improve the comment on __memcmpable.

	* include/bits/cpp_type_traits.h (__memcpyable): Fix comment.
parent 0b0908c1
2020-03-04 Jonathan Wakely <jwakely@redhat.com>
* include/bits/cpp_type_traits.h (__memcpyable): Fix comment.
2020-03-04 Patrick Palka <ppalka@redhat.com> 2020-03-04 Patrick Palka <ppalka@redhat.com>
PR libstdc++/94017 PR libstdc++/94017
......
...@@ -429,10 +429,9 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) ...@@ -429,10 +429,9 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3)
enum { __value = __is_trivially_copyable(_Tp) }; enum { __value = __is_trivially_copyable(_Tp) };
}; };
// Cannot use memcpy/memmove/memcmp on volatile types, but before C++20 // Cannot use memcpy/memmove/memcmp on volatile types even if they are
// iterator_traits<volatile T*>::value_type is volatile T and so the // trivially copyable, so ensure __memcpyable<volatile int*, volatile int*>
// partial specializations below match for volatile-qualified pointers // and similar will be false.
// e.g. __memcpyable<volatile int*, volatile int*, volatile int>.
template<typename _Tp> template<typename _Tp>
struct __is_nonvolatile_trivially_copyable<volatile _Tp> struct __is_nonvolatile_trivially_copyable<volatile _Tp>
{ {
...@@ -457,6 +456,10 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3) ...@@ -457,6 +456,10 @@ __INT_N(__GLIBCXX_TYPE_INT_N_3)
{ }; { };
// Whether two iterator types can be used with memcmp. // Whether two iterator types can be used with memcmp.
// This trait only says it's well-formed to use memcmp, not that it
// gives the right answer for a given algorithm. So for example, std::equal
// needs to add additional checks that the types are integers or pointers,
// because other trivially copyable types can overload operator==.
template<typename _Iter1, typename _Iter2> template<typename _Iter1, typename _Iter2>
struct __memcmpable struct __memcmpable
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment