Updates from BitShares FC #22

Closed
nathanielhourt wants to merge 693 commits from dapp-support into latest-fc
5 changed files with 0 additions and 182 deletions
Showing only changes of commit 063be69d07 - Show all commits

View file

@ -5,7 +5,6 @@
#include <fc/io/varint.hpp>
#include <fc/optional.hpp>
#include <fc/fwd.hpp>
#include <fc/smart_ref_fwd.hpp>
#include <fc/array.hpp>
#include <fc/time.hpp>
#include <fc/filesystem.hpp>
@ -219,19 +218,6 @@ namespace fc {
FC_ASSERT( _max_depth > 0 );
fc::raw::unpack( *v, _max_depth - 1 ); // TODO not sure about this
}
template<typename Stream, typename T>
void pack( Stream& s, const fc::smart_ref<T>& v, uint32_t _max_depth )
{
FC_ASSERT( _max_depth > 0 );
fc::raw::pack( s, *v, _max_depth - 1 );
}
template<typename Stream, typename T>
void unpack( Stream& s, fc::smart_ref<T>& v, uint32_t _max_depth )
{
FC_ASSERT( _max_depth > 0 );
fc::raw::unpack( s, *v, _max_depth - 1 );
}
// optional
template<typename Stream, typename T>

View file

@ -7,7 +7,6 @@
#include <fc/string.hpp>
#include <fc/optional.hpp>
#include <fc/smart_ref_fwd.hpp>
#include <fc/container/flat_fwd.hpp>
#include <fc/container/deque_fwd.hpp>
@ -87,14 +86,6 @@ namespace fc {
return n.c_str();
}
};
template<typename T> struct get_typename< fc::smart_ref<T> >
{
static const char* name()
{
static std::string n = std::string("fc::smart_ref<") + get_typename<T>::name() + std::string(">");
return n.c_str();
}
};
struct unsigned_int;
class variant_object;

View file

@ -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<typename T>
class smart_ref {
public:
template<typename U> smart_ref( U&& u );
template<typename U, typename V> smart_ref( U&& u, V&& v );
template<typename U, typename V, typename X, typename Y> 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<typename U>
T& operator = ( U&& u );
T& operator = ( smart_ref&& u );
T& operator = ( const smart_ref& u );
~smart_ref();
private:
T* impl;
};
}

View file

@ -1,105 +0,0 @@
#pragma once
#include <fc/utility.hpp>
#include <fc/smart_ref_fwd.hpp>
#include <new>
namespace fc {
namespace detail {
template<typename A, typename U>
struct insert_op {
typedef decltype( *((A*)0) << *((typename fc::remove_reference<U>::type*)0) ) type;
};
template<typename A, typename U>
struct extract_op {
A* a;
U* u;
typedef decltype( *a >> *u ) type;
};
}
template<typename T, typename U>
auto operator << ( U& u, const smart_ref<T>& f ) -> typename detail::insert_op<U,T>::type { return u << *f; }
template<typename T, typename U>
auto operator >> ( U& u, smart_ref<T>& f ) -> typename detail::extract_op<U,T>::type { return u >> *f; }
template<typename T>
bool smart_ref<T>::operator !()const { return !(**this); }
template<typename T>
template<typename U>
smart_ref<T>::smart_ref( U&& u ) {
impl = new (this) T( fc::forward<U>(u) );
}
template<typename T>
template<typename U,typename V>
smart_ref<T>::smart_ref( U&& u, V&& v ) {
impl = new T( fc::forward<U>(u), fc::forward<V>(v) );
}
template<typename T>
template<typename U,typename V,typename X,typename Y>
smart_ref<T>::smart_ref( U&& u, V&& v, X&& x, Y&& y ) {
impl = new T( fc::forward<U>(u), fc::forward<V>(v), fc::forward<X>(x), fc::forward<Y>(y) );
}
template<typename T>
smart_ref<T>::smart_ref() {
impl = new T;
}
template<typename T>
smart_ref<T>::smart_ref( const smart_ref<T>& f ){
impl = new T( *f );
}
template<typename T>
smart_ref<T>::smart_ref( smart_ref<T>&& f ){
impl = new T( fc::move(*f) );
}
template<typename T>
smart_ref<T>::operator T&() { return *impl; }
template<typename T>
smart_ref<T>::operator const T&()const { return *impl; }
template<typename T>
T& smart_ref<T>::operator*() { return *impl; }
template<typename T>
const T& smart_ref<T>::operator*()const { return *impl; }
template<typename T>
const T* smart_ref<T>::operator->()const { return impl; }
template<typename T>
T* smart_ref<T>::operator->(){ return impl; }
template<typename T>
smart_ref<T>::~smart_ref() {
delete impl;
}
template<typename T>
template<typename U>
T& smart_ref<T>::operator = ( U&& u ) {
return **this = fc::forward<U>(u);
}
template<typename T>
T& smart_ref<T>::operator = ( smart_ref<T>&& u ) {
if( &u == this ) return *impl;
delete impl;
impl = u.impl;
u.impl = nullptr;
return *impl;
}
template<typename T>
T& smart_ref<T>::operator = ( const smart_ref<T>& u ) {
if( &u == this ) return *impl;
return **this = *u;
}
} // namespace fc

View file

@ -14,7 +14,6 @@
#include <fc/string.hpp>
#include <fc/container/deque_fwd.hpp>
#include <fc/container/flat_fwd.hpp>
#include <fc/smart_ref_fwd.hpp>
#include <boost/multi_index_container_fwd.hpp>
#ifdef FC_ASSERT
@ -62,8 +61,6 @@ namespace fc
template<typename T, typename... Args> void to_variant( const boost::multi_index_container<T,Args...>& s, variant& v, uint32_t max_depth );
template<typename T, typename... Args> void from_variant( const variant& v, boost::multi_index_container<T,Args...>& s, uint32_t max_depth );
template<typename T> void to_variant( const smart_ref<T>& s, variant& v, uint32_t max_depth );
template<typename T> void from_variant( const variant& v, smart_ref<T>& s, uint32_t max_depth );
template<typename T> void to_variant( const safe<T>& s, variant& v, uint32_t max_depth );
template<typename T> void from_variant( const variant& v, safe<T>& s, uint32_t max_depth );
template<typename T> void to_variant( const std::unique_ptr<T>& s, variant& v, uint32_t max_depth );
@ -624,16 +621,6 @@ namespace fc
s.value = v.as<T>( max_depth );
}
template<typename T>
void to_variant( const smart_ref<T>& s, variant& v, uint32_t max_depth ) {
to_variant( *s, v, max_depth );
}
template<typename T>
void from_variant( const variant& v, smart_ref<T>& s, uint32_t max_depth ) {
from_variant( v, *s, max_depth );
}
template<typename T, typename... Args>
void to_variant( const boost::multi_index_container<T,Args...>& c, variant& v, uint32_t max_depth )
{