[PATCH] Fix typos in experimental::shared_ptr

Jonathan Wakely jwakely@redhat.com
Tue Oct 18 18:30:00 GMT 2016


A couple of minor things I found whlie reviewing this code.

	* include/experimental/bits/shared_ptr.h (shared_ptr(shared_ptr&&)):
	Remove const from parameter.
	(operator<(const shared_ptr<T>&, nullptr_t)): Use correct
	specialization of std::less.
	* testsuite/experimental/memory/shared_ptr/comparison/comparison.cc:
	Test comparison with nullptr and actually call test functions.

Tested x86_64-linux, comitted to trunk.


-------------- next part --------------
commit dd9bc04a6df29881ccbf2e68ae21b6f23cc71dd7
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Oct 18 18:31:48 2016 +0100

    Fix typos in experimental::shared_ptr
    
    	* include/experimental/bits/shared_ptr.h (shared_ptr(shared_ptr&&)):
    	Remove const from parameter.
    	(operator<(const shared_ptr<T>&, nullptr_t)): Use correct
    	specialization of std::less.
    	* testsuite/experimental/memory/shared_ptr/comparison/comparison.cc:
    	Test comparison with nullptr and actually call test functions.

diff --git a/libstdc++-v3/include/experimental/bits/shared_ptr.h b/libstdc++-v3/include/experimental/bits/shared_ptr.h
index d61789a..7a232f4 100644
--- a/libstdc++-v3/include/experimental/bits/shared_ptr.h
+++ b/libstdc++-v3/include/experimental/bits/shared_ptr.h
@@ -672,7 +672,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	shared_ptr(const shared_ptr<_Tp1>& __r) noexcept
 	: _Base_type(__r) { }
 
-      shared_ptr(const shared_ptr<_Tp>&& __r) noexcept
+      shared_ptr(shared_ptr&& __r) noexcept
       : _Base_type(std::move(__r)) { }
 
       template<typename _Tp1, typename = _Compatible<_Tp1>>
@@ -815,7 +815,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
      operator<(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
      {
        using __elem_t = typename shared_ptr<_Tp>::element_type;
-       return std::less<__elem_t>()(__a.get(), nullptr);
+       return std::less<__elem_t*>()(__a.get(), nullptr);
      }
 
    template<typename _Tp>
diff --git a/libstdc++-v3/testsuite/experimental/memory/shared_ptr/comparison/comparison.cc b/libstdc++-v3/testsuite/experimental/memory/shared_ptr/comparison/comparison.cc
index fafa6eb..d733811 100644
--- a/libstdc++-v3/testsuite/experimental/memory/shared_ptr/comparison/comparison.cc
+++ b/libstdc++-v3/testsuite/experimental/memory/shared_ptr/comparison/comparison.cc
@@ -73,8 +73,18 @@ test02()
   return 0;
 }
 
+void
+test03()
+{
+  std::experimental::shared_ptr<A[5]> a(new A[5]);
+  VERIFY( nullptr < a );
+}
+
 int
 main()
 {
+  test01();
+  test02();
+  test03();
   return 0;
 }


More information about the Libstdc++ mailing list