[vlc-commits] [Git][videolan/vlc][master] vlc_shared_data_ptr: accept implicit ctor for null

Steve Lhomme (@robUx4) gitlab at videolan.org
Sat Oct 1 04:44:44 UTC 2022



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
98d7763c by Romain Vimont at 2022-10-01T04:29:53+00:00
vlc_shared_data_ptr: accept implicit ctor for null

The main constructor, accepting a pointer, is explicit:

    my_ptr_type *p = ...;
    MySharedPtr ptr = p;   /* invalid */
    MySharedPtr ptr{ p };  /* ok */

This prevents to mistakenly assign a pointer to a shared pointer.

However, assignment to nullptr should be acceptable:

    MySharedPtr ptr = nullptr;  /* should be ok */

- - - - -


1 changed file:

- include/vlc_cxx_helpers.hpp


Changes:

=====================================
include/vlc_cxx_helpers.hpp
=====================================
@@ -171,6 +171,11 @@ public:
             HOLD(ptr);
     }
 
+    vlc_shared_data_ptr(std::nullptr_t)
+        : ptr(nullptr)
+    {
+    }
+
     vlc_shared_data_ptr(const vlc_shared_data_ptr &other)
         : vlc_shared_data_ptr(other.ptr) {}
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/98d7763c81cbe334f2dc4f10102c71cf13a095e8

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/98d7763c81cbe334f2dc4f10102c71cf13a095e8
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list