@@ -969,7 +969,10 @@ class basic_observer_ptr final {
969969 }
970970 }
971971
972- // / Create an observer pointer from an owning pointer.
972+ /* *
973+ * \brief Create an observer pointer from an owning pointer of a convertible type.
974+ * \param owner The owner pointer to observe (can be null)
975+ */
973976 template <
974977 typename U,
975978 typename D,
@@ -983,6 +986,26 @@ class basic_observer_ptr final {
983986 }
984987 }
985988
989+ /* *
990+ * \brief Create an observer pointer from an owning pointer of a different type.
991+ * \param manager The owner pointer to copy the observed data from
992+ * \param value The casted pointer value to observe
993+ * \note The raw pointer `value` may or may not be related to the raw pointer
994+ * owner by `manager`. This could be a pointer to any other object which is known
995+ * to have the same lifetime.
996+ */
997+ template <
998+ typename U,
999+ typename D,
1000+ typename P,
1001+ typename enable = std::enable_if_t <std::is_same_v<Policy, typename P::observer_policy>>>
1002+ basic_observer_ptr (const basic_observable_ptr<U, D, P>& manager, T* value) noexcept :
1003+ block (manager.block), data(value) {
1004+ if (block) {
1005+ block->push_ref ();
1006+ }
1007+ }
1008+
9861009 /* *
9871010 * \brief Copy an existing @ref basic_observer_ptr instance
9881011 * \param value The existing observer pointer to copy
@@ -1010,12 +1033,9 @@ class basic_observer_ptr final {
10101033 * \brief Copy an existing @ref basic_observer_ptr instance with explicit casting
10111034 * \param manager The observer pointer to copy the observed data from
10121035 * \param value The casted pointer value to observe
1013- * \note After this smart pointer is created, the source
1014- * pointer is set to null and looses ownership. The deleter
1015- * is default constructed. The raw pointer `value` may or may
1016- * not be related to the raw pointer observed by `manager`.
1017- * This could be a pointer to any other object which is known to
1018- * have the same lifetime.
1036+ * \note The raw pointer `value` may or may not be related to the raw pointer
1037+ * observed by `manager`. This could be a pointer to any other object which is known
1038+ * to have the same lifetime.
10191039 */
10201040 template <typename U>
10211041 basic_observer_ptr (const basic_observer_ptr<U, Policy>& manager, T* value) noexcept :
@@ -1054,11 +1074,9 @@ class basic_observer_ptr final {
10541074 * \brief Move from an existing @ref basic_observer_ptr instance with explicit casting
10551075 * \param manager The observer pointer to copy the observed data from
10561076 * \param value The casted pointer value to observe
1057- * \note After this smart pointer is created, the source
1058- * pointer is set to null and looses ownership. The deleter
1059- * is default constructed. The raw pointer `value` may or may
1060- * not be related to the raw pointer observed by `manager`.
1061- * This could be a pointer to any other object which is known to
1077+ * \note After this smart pointer is created, the source pointer `manager` is set to
1078+ * null. The raw pointer `value` may or may not be related to the raw pointer observed
1079+ * by `manager`. This could be a pointer to any other object which is known to
10621080 * have the same lifetime.
10631081 */
10641082 template <typename U>
0 commit comments