Commits

Stefan Zimmermann committed 4b87043

fixed automatic unsync manager casting

Comments (0)

Files changed (3)

include/carefree-objects/const_methods.hpp

       std::shared_ptr<T>(obj)
     {}
 
+    inline const_methods(const std::shared_ptr<T> &manager) :
+      std::shared_ptr<T>(manager)
+    {}
+
     inline const_methods
     (const const_methods<T, false, BASES...> &methods) :
 
       std::shared_ptr<T>(methods)
     {}
 
-    template<typename T_other, typename... BASES_other>
-    inline const_methods
-    (const const_methods<T_other, false, BASES_other...> &methods) :
-
-      std::shared_ptr<T>(methods)
-    {}
-
     inline const managed<T, false, BASES...>& manager() const
     {
       return static_cast<const managed<T, false, BASES...>&>(*this);
     {}                                                                  \
                                                                         \
     inline cfo_managed_const_methods                                    \
+      (const std::shared_ptr<cfo_T> &manager) :                         \
+                                                                        \
+      cfo::const_methods<cfo_T, false, cfo_BASES...>(manager)           \
+    {}                                                                  \
+                                                                        \
+    inline cfo_managed_const_methods                                    \
       (const cfo_managed_const_methods<cfo_T, false, cfo_BASES...>      \
        &methods) :                                                      \
                                                                         \
       cfo::const_methods<cfo_T, false, cfo_BASES...>(methods)           \
       {}                                                                \
                                                                         \
-    template<typename cfo_T_other, typename... cfo_BASES_other>         \
-      inline cfo_managed_const_methods                                  \
-      (const cfo_managed_const_methods                                  \
-       <cfo_T_other, false, cfo_BASES_other...>                         \
-       &methods) :                                                      \
-                                                                        \
-      cfo::const_methods<cfo_T, false, cfo_BASES...>(methods)           \
-      {}                                                                \
-                                                                        \
     inline cfo_managed_const_methods                                    \
       (const cfo::managed<cfo_T, true, cfo_BASES...> &manager,          \
        bool shared) :                                                   \
     {}                                                                  \
                                                                         \
     inline cfo_managed_const_methods                                    \
-      (const cfo_managed_const_methods<cfo_T, false, cfo_BASES...>      \
-       &methods) :                                                      \
+      (const std::shared_ptr<cfo_T> &manager) :                         \
                                                                         \
       BASE::template cfo_managed_const_methods                          \
       <cfo_T, false, cfo_BASES...>                                      \
-      (methods)                                                         \
+      (manager)                                                         \
     {}                                                                  \
                                                                         \
-    template<typename cfo_T_other, typename... cfo_BASES_other>         \
-      inline cfo_managed_const_methods                                  \
-      (const cfo_managed_const_methods                                  \
-       <cfo_T_other, false, cfo_BASES_other...>                         \
+    inline cfo_managed_const_methods                                    \
+      (const cfo_managed_const_methods<cfo_T, false, cfo_BASES...>      \
        &methods) :                                                      \
                                                                         \
       BASE::template cfo_managed_const_methods                          \

include/carefree-objects/managed.hpp

   {
     friend T;
 
+    template<typename T_other, bool SYNC, typename... BASES_other>
+    friend class managed;
+
   protected:
     inline managed(T *obj) :
       T::template cfo_managed_methods<T, false, BASES...>(obj)
     inline managed
       (const managed<T_other, false, BASES_other...> &other_manager) :
 
-      T::template cfo_managed_methods<T, false, BASES...>(other_manager)
+      T::template cfo_managed_methods<T, false, BASES...>
+      (std::static_pointer_cast<T>
+       (static_cast<const std::shared_ptr<T_other>&>(other_manager)))
     {}
 
     inline T* operator->() const

include/carefree-objects/methods.hpp

       T::template cfo_managed_const_methods<T, false, BASES...>(obj)
     {}
 
-    inline methods(const methods<T, false, BASES...> &methods) :
-      T::template cfo_managed_const_methods<T, false, BASES...>(methods)
+    inline methods(const std::shared_ptr<T> &manager) :
+      T::template cfo_managed_const_methods<T, false, BASES...>(manager)
     {}
 
-    template<typename T_other, typename... BASES_other>
-    inline methods
-    (const methods<T_other, false, BASES_other...> &methods) :
-
+    inline methods(const methods<T, false, BASES...> &methods) :
       T::template cfo_managed_const_methods<T, false, BASES...>(methods)
     {}
 
       cfo::methods<cfo_T, false, cfo_BASES...>(obj)                     \
     {}                                                                  \
                                                                         \
+    inline cfo_managed_methods(const std::shared_ptr<cfo_T> &manager) : \
+      cfo::methods<cfo_T, false, cfo_BASES...>(manager)                 \
+    {}                                                                  \
+                                                                        \
     inline cfo_managed_methods                                          \
       (const cfo_managed_methods<cfo_T, false, cfo_BASES...>            \
        &methods) :                                                      \
       cfo::methods<cfo_T, false, cfo_BASES...>(methods)                 \
       {}                                                                \
                                                                         \
-    template<typename cfo_T_other, typename... cfo_BASES_other>         \
-    inline cfo_managed_methods                                          \
-      (const cfo_managed_methods                                        \
-       <cfo_T_other, false, cfo_BASES_other...>                         \
-       &methods) :                                                      \
-                                                                        \
-      cfo::methods<cfo_T, false, cfo_BASES...>(methods)                 \
-      {}                                                                \
-                                                                        \
   public:                                                               \
     inline cfo_managed_methods                                          \
       (const cfo::managed<cfo_T, true, cfo_BASES...> &manager) :        \
       <cfo_T, false, cfo_BASES...>(obj)                                 \
     {}                                                                  \
                                                                         \
+    inline cfo_managed_methods(const std::shared_ptr<cfo_T> &manager) : \
+      BASE::template cfo_managed_methods<cfo_T, false, cfo_BASES...>    \
+      (manager)                                                         \
+    {}                                                                  \
+                                                                        \
     inline cfo_managed_methods                                          \
       (const cfo_managed_methods<cfo_T, false, cfo_BASES...>            \
        &methods) :                                                      \
       (methods)                                                         \
     {}                                                                  \
                                                                         \
-    template<typename cfo_T_other, typename... cfo_BASES_other>         \
-    inline cfo_managed_methods                                          \
-      (const cfo_managed_methods                                        \
-       <cfo_T_other, false, cfo_BASES_other...>                         \
-       &methods) :                                                      \
-                                                                        \
-      BASE::template cfo_managed_methods<cfo_T, false, cfo_BASES...>    \
-      (methods)                                                         \
-    {}                                                                  \
-                                                                        \
   public:                                                               \
     inline cfo_managed_methods                                          \
       (const cfo::managed<cfo_T, true, cfo_BASES...> &manager) :        \