From 19590fd413a0f4fb06c735b3af209678021d5890 Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 15 Feb 2019 08:23:05 -0500 Subject: [PATCH] Removal of smart_ref --- include/fc/io/raw.hpp | 14 ----- include/fc/reflect/typename.hpp | 9 --- include/fc/smart_ref_fwd.hpp | 41 ------------- include/fc/smart_ref_impl.hpp | 105 -------------------------------- include/fc/variant.hpp | 13 ---- 5 files changed, 182 deletions(-) delete mode 100644 include/fc/smart_ref_fwd.hpp delete mode 100644 include/fc/smart_ref_impl.hpp diff --git a/include/fc/io/raw.hpp b/include/fc/io/raw.hpp index dc582d240..2268e3720 100644 --- a/include/fc/io/raw.hpp +++ b/include/fc/io/raw.hpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -219,19 +218,6 @@ namespace fc { FC_ASSERT( _max_depth > 0 ); fc::raw::unpack( *v, _max_depth - 1 ); // TODO not sure about this } - template - void pack( Stream& s, const fc::smart_ref& v, uint32_t _max_depth ) - { - FC_ASSERT( _max_depth > 0 ); - fc::raw::pack( s, *v, _max_depth - 1 ); - } - - template - void unpack( Stream& s, fc::smart_ref& v, uint32_t _max_depth ) - { - FC_ASSERT( _max_depth > 0 ); - fc::raw::unpack( s, *v, _max_depth - 1 ); - } // optional template diff --git a/include/fc/reflect/typename.hpp b/include/fc/reflect/typename.hpp index 848938fc0..7329494b2 100644 --- a/include/fc/reflect/typename.hpp +++ b/include/fc/reflect/typename.hpp @@ -7,7 +7,6 @@ #include #include -#include #include #include @@ -87,14 +86,6 @@ namespace fc { return n.c_str(); } }; - template struct get_typename< fc::smart_ref > - { - static const char* name() - { - static std::string n = std::string("fc::smart_ref<") + get_typename::name() + std::string(">"); - return n.c_str(); - } - }; struct unsigned_int; class variant_object; diff --git a/include/fc/smart_ref_fwd.hpp b/include/fc/smart_ref_fwd.hpp deleted file mode 100644 index 145dae5d9..000000000 --- a/include/fc/smart_ref_fwd.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once - -namespace fc { - /** - * @brief Used to forward declare value types and break circular dependencies or use heap allocation - * - * A smart reference is heap allocated, move-aware, and is gauranteed to never be null (except after a move) - */ - template - class smart_ref { - public: - template smart_ref( U&& u ); - template smart_ref( U&& u, V&& v ); - template smart_ref( U&& u, V&& v, X&&, Y&& ); - smart_ref(); - - smart_ref( const smart_ref& f ); - smart_ref( smart_ref&& f ); - - operator const T&()const; - operator T&(); - - T& operator*(); - const T& operator*()const; - const T* operator->()const; - - T* operator->(); - bool operator !()const; - - template - T& operator = ( U&& u ); - - T& operator = ( smart_ref&& u ); - T& operator = ( const smart_ref& u ); - - ~smart_ref(); - - private: - T* impl; - }; -} diff --git a/include/fc/smart_ref_impl.hpp b/include/fc/smart_ref_impl.hpp deleted file mode 100644 index fd696941b..000000000 --- a/include/fc/smart_ref_impl.hpp +++ /dev/null @@ -1,105 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace fc { - - namespace detail { - - template - struct insert_op { - typedef decltype( *((A*)0) << *((typename fc::remove_reference::type*)0) ) type; - }; - - template - struct extract_op { - A* a; - U* u; - typedef decltype( *a >> *u ) type; - }; - } - - template - auto operator << ( U& u, const smart_ref& f ) -> typename detail::insert_op::type { return u << *f; } - - template - auto operator >> ( U& u, smart_ref& f ) -> typename detail::extract_op::type { return u >> *f; } - - template - bool smart_ref::operator !()const { return !(**this); } - - template - template - smart_ref::smart_ref( U&& u ) { - impl = new (this) T( fc::forward(u) ); - } - - template - template - smart_ref::smart_ref( U&& u, V&& v ) { - impl = new T( fc::forward(u), fc::forward(v) ); - } - template - template - smart_ref::smart_ref( U&& u, V&& v, X&& x, Y&& y ) { - impl = new T( fc::forward(u), fc::forward(v), fc::forward(x), fc::forward(y) ); - } - - template - smart_ref::smart_ref() { - impl = new T; - } - template - smart_ref::smart_ref( const smart_ref& f ){ - impl = new T( *f ); - } - template - smart_ref::smart_ref( smart_ref&& f ){ - impl = new T( fc::move(*f) ); - } - - template - smart_ref::operator T&() { return *impl; } - template - smart_ref::operator const T&()const { return *impl; } - - template - T& smart_ref::operator*() { return *impl; } - template - const T& smart_ref::operator*()const { return *impl; } - template - const T* smart_ref::operator->()const { return impl; } - - template - T* smart_ref::operator->(){ return impl; } - - template - smart_ref::~smart_ref() { - delete impl; - } - - template - template - T& smart_ref::operator = ( U&& u ) { - return **this = fc::forward(u); - } - - template - T& smart_ref::operator = ( smart_ref&& u ) { - if( &u == this ) return *impl; - delete impl; - impl = u.impl; - u.impl = nullptr; - return *impl; - } - - template - T& smart_ref::operator = ( const smart_ref& u ) { - if( &u == this ) return *impl; - return **this = *u; - } - -} // namespace fc - diff --git a/include/fc/variant.hpp b/include/fc/variant.hpp index 455a4f445..03b7eda9a 100644 --- a/include/fc/variant.hpp +++ b/include/fc/variant.hpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #ifdef FC_ASSERT @@ -62,8 +61,6 @@ namespace fc template void to_variant( const boost::multi_index_container& s, variant& v, uint32_t max_depth ); template void from_variant( const variant& v, boost::multi_index_container& s, uint32_t max_depth ); - template void to_variant( const smart_ref& s, variant& v, uint32_t max_depth ); - template void from_variant( const variant& v, smart_ref& s, uint32_t max_depth ); template void to_variant( const safe& s, variant& v, uint32_t max_depth ); template void from_variant( const variant& v, safe& s, uint32_t max_depth ); template void to_variant( const std::unique_ptr& s, variant& v, uint32_t max_depth ); @@ -624,16 +621,6 @@ namespace fc s.value = v.as( max_depth ); } - template - void to_variant( const smart_ref& s, variant& v, uint32_t max_depth ) { - to_variant( *s, v, max_depth ); - } - - template - void from_variant( const variant& v, smart_ref& s, uint32_t max_depth ) { - from_variant( v, *s, max_depth ); - } - template void to_variant( const boost::multi_index_container& c, variant& v, uint32_t max_depth ) {