FC Updates from BitShares and myself #21
10 changed files with 28 additions and 34 deletions
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
#include <fc/log/logger.hpp>
|
||||
#include <fc/optional.hpp>
|
||||
#include <fc/utility.hpp>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <unordered_map>
|
||||
|
|
@ -167,10 +166,10 @@ namespace fc
|
|||
{
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1700)
|
||||
return std::make_shared<unhandled_exception>( log_message(),
|
||||
std::copy_exception(fc::forward<T>(e)) );
|
||||
std::copy_exception(std::forward<T>(e)) );
|
||||
#else
|
||||
return std::make_shared<unhandled_exception>( log_message(),
|
||||
std::make_exception_ptr(fc::forward<T>(e)) );
|
||||
std::make_exception_ptr(std::forward<T>(e)) );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <fc/utility.hpp>
|
||||
#include <fc/fwd.hpp>
|
||||
#include <cstdint>
|
||||
#include <new>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
|
@ -41,10 +41,10 @@ namespace fc {
|
|||
|
||||
|
||||
template<typename T, unsigned int S, typename U, typename A>
|
||||
auto operator + ( const fwd<T,S,A>& x, U&& u ) -> typename detail::add<T,U>::type { return *x+fc::forward<U>(u); }
|
||||
auto operator + ( const fwd<T,S,A>& x, U&& u ) -> typename detail::add<T,U>::type { return *x+std::forward<U>(u); }
|
||||
|
||||
template<typename T, unsigned int S, typename U, typename A>
|
||||
auto operator - ( const fwd<T,S,A>& x, U&& u ) -> typename detail::sub<T,U>::type { return *x-fc::forward<U>(u); }
|
||||
auto operator - ( const fwd<T,S,A>& x, U&& u ) -> typename detail::sub<T,U>::type { return *x-std::forward<U>(u); }
|
||||
|
||||
template<typename T, unsigned int S, typename U, typename A>
|
||||
auto operator << ( U& u, const fwd<T,S,A>& f ) -> typename detail::insert_op<U,T>::type { return u << *f; }
|
||||
|
|
@ -63,20 +63,20 @@ namespace fc {
|
|||
template<typename U>
|
||||
fwd<T,S,A>::fwd( U&& u ) {
|
||||
check_size<sizeof(T),sizeof(_store)>();
|
||||
new (this) T( fc::forward<U>(u) );
|
||||
new (this) T( std::forward<U>(u) );
|
||||
}
|
||||
|
||||
template<typename T,unsigned int S,typename A>
|
||||
template<typename U,typename V>
|
||||
fwd<T,S,A>::fwd( U&& u, V&& v ) {
|
||||
check_size<sizeof(T),sizeof(_store)>();
|
||||
new (this) T( fc::forward<U>(u), fc::forward<V>(v) );
|
||||
new (this) T( std::forward<U>(u), std::forward<V>(v) );
|
||||
}
|
||||
template<typename T,unsigned int S,typename A>
|
||||
template<typename U,typename V,typename X,typename Y>
|
||||
fwd<T,S,A>::fwd( U&& u, V&& v, X&& x, Y&& y ) {
|
||||
check_size<sizeof(T),sizeof(_store)>();
|
||||
new (this) T( fc::forward<U>(u), fc::forward<V>(v), fc::forward<X>(x), fc::forward<Y>(y) );
|
||||
new (this) T( std::forward<U>(u), std::forward<V>(v), std::forward<X>(x), std::forward<Y>(y) );
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ namespace fc {
|
|||
template<typename T,unsigned int S, typename A>
|
||||
template<typename U>
|
||||
T& fwd<T,S,A>::operator = ( U&& u ) {
|
||||
return **this = fc::forward<U>(u);
|
||||
return **this = std::forward<U>(u);
|
||||
}
|
||||
|
||||
template<typename T,unsigned int S, typename A>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
#pragma once
|
||||
#include <fc/utility.hpp>
|
||||
#include <assert.h>
|
||||
#include <utility>
|
||||
|
||||
|
||||
namespace fc {
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
|
|
@ -81,14 +79,14 @@ namespace fc {
|
|||
optional( U&& u )
|
||||
:_valid(true)
|
||||
{
|
||||
new ((char*)ptr()) T( fc::forward<U>(u) );
|
||||
new ((char*)ptr()) T( std::forward<U>(u) );
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
optional& operator=( U&& u )
|
||||
{
|
||||
reset();
|
||||
new (ptr()) T( fc::forward<U>(u) );
|
||||
new (ptr()) T( std::forward<U>(u) );
|
||||
_valid = true;
|
||||
return *this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ namespace fc {
|
|||
|
||||
template<typename CompletionHandler>
|
||||
void on_complete( CompletionHandler&& c ) {
|
||||
_on_complete( new detail::completion_handler_impl<CompletionHandler,T>(fc::forward<CompletionHandler>(c)) );
|
||||
_on_complete( new detail::completion_handler_impl<CompletionHandler,T>(std::forward<CompletionHandler>(c)) );
|
||||
}
|
||||
protected:
|
||||
promise( const char* desc ):promise_base(desc){}
|
||||
|
|
@ -184,7 +184,7 @@ namespace fc {
|
|||
|
||||
template<typename CompletionHandler>
|
||||
void on_complete( CompletionHandler&& c ) {
|
||||
_on_complete( new detail::completion_handler_impl<CompletionHandler,void>(fc::forward<CompletionHandler>(c)) );
|
||||
_on_complete( new detail::completion_handler_impl<CompletionHandler,void>(std::forward<CompletionHandler>(c)) );
|
||||
}
|
||||
protected:
|
||||
promise( const char* desc ):promise_base(desc){}
|
||||
|
|
@ -273,7 +273,7 @@ namespace fc {
|
|||
*/
|
||||
template<typename CompletionHandler>
|
||||
void on_complete( CompletionHandler&& c ) {
|
||||
m_prom->on_complete( fc::forward<CompletionHandler>(c) );
|
||||
m_prom->on_complete( std::forward<CompletionHandler>(c) );
|
||||
}
|
||||
private:
|
||||
friend class thread;
|
||||
|
|
@ -334,7 +334,7 @@ namespace fc {
|
|||
|
||||
template<typename CompletionHandler>
|
||||
void on_complete( CompletionHandler&& c ) {
|
||||
m_prom->on_complete( fc::forward<CompletionHandler>(c) );
|
||||
m_prom->on_complete( std::forward<CompletionHandler>(c) );
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ namespace fc {
|
|||
typedef decltype(f()) Result;
|
||||
typedef typename fc::deduce<Functor>::type FunctorType;
|
||||
typename task<Result,sizeof(FunctorType)>::ptr tsk =
|
||||
task<Result,sizeof(FunctorType)>::create( fc::forward<Functor>(f), desc );
|
||||
task<Result,sizeof(FunctorType)>::create( std::forward<Functor>(f), desc );
|
||||
tsk->retain(); // HERE BE DRAFONS
|
||||
fc::future<Result> r( std::dynamic_pointer_cast< promise<Result> >(tsk) );
|
||||
detail::get_worker_pool().post( tsk.get() );
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ namespace fc {
|
|||
task( Functor&& f, const char* desc ):promise_base(desc), task_base(&_functor), promise<R>(desc) {
|
||||
typedef typename fc::deduce<Functor>::type FunctorType;
|
||||
static_assert( sizeof(f) <= sizeof(_functor), "sizeof(Functor) is larger than FunctorSize" );
|
||||
new ((char*)&_functor) FunctorType( fc::forward<Functor>(f) );
|
||||
new ((char*)&_functor) FunctorType( std::forward<Functor>(f) );
|
||||
_destroy_functor = &detail::functor_destructor<FunctorType>::destroy;
|
||||
|
||||
_promise_impl = static_cast<promise<R>*>(this);
|
||||
|
|
@ -157,7 +157,7 @@ namespace fc {
|
|||
task( Functor&& f, const char* desc ):promise_base(desc), task_base(&_functor), promise<void>(desc) {
|
||||
typedef typename fc::deduce<Functor>::type FunctorType;
|
||||
static_assert( sizeof(f) <= sizeof(_functor), "sizeof(Functor) is larger than FunctorSize" );
|
||||
new ((char*)&_functor) FunctorType( fc::forward<Functor>(f) );
|
||||
new ((char*)&_functor) FunctorType( std::forward<Functor>(f) );
|
||||
_destroy_functor = &detail::functor_destructor<FunctorType>::destroy;
|
||||
|
||||
_promise_impl = static_cast<promise<void>*>(this);
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ namespace fc {
|
|||
typedef decltype(f()) Result;
|
||||
typedef typename fc::deduce<Functor>::type FunctorType;
|
||||
typename task<Result,sizeof(FunctorType)>::ptr tsk =
|
||||
task<Result,sizeof(FunctorType)>::create( fc::forward<Functor>(f), desc );
|
||||
task<Result,sizeof(FunctorType)>::create( std::forward<Functor>(f), desc );
|
||||
tsk->retain(); // HERE BE DRAFONS
|
||||
fc::future<Result> r( std::dynamic_pointer_cast< promise<Result> >(tsk) );
|
||||
async_task(tsk.get(),prio);
|
||||
|
|
@ -111,7 +111,7 @@ namespace fc {
|
|||
const char* desc FC_TASK_NAME_DEFAULT_ARG, priority prio = priority()) -> fc::future<decltype(f())> {
|
||||
typedef decltype(f()) Result;
|
||||
typename task<Result,sizeof(Functor)>::ptr tsk =
|
||||
task<Result,sizeof(Functor)>::create( fc::forward<Functor>(f), desc );
|
||||
task<Result,sizeof(Functor)>::create( std::forward<Functor>(f), desc );
|
||||
tsk->retain(); // HERE BE DRAFONS
|
||||
fc::future<Result> r( std::dynamic_pointer_cast< promise<Result> >(tsk) );
|
||||
async_task(tsk.get(),prio,when);
|
||||
|
|
@ -225,11 +225,11 @@ namespace fc {
|
|||
|
||||
template<typename Functor>
|
||||
auto async( Functor&& f, const char* desc FC_TASK_NAME_DEFAULT_ARG, priority prio = priority()) -> fc::future<decltype(f())> {
|
||||
return fc::thread::current().async( fc::forward<Functor>(f), desc, prio );
|
||||
return fc::thread::current().async( std::forward<Functor>(f), desc, prio );
|
||||
}
|
||||
template<typename Functor>
|
||||
auto schedule( Functor&& f, const fc::time_point& t, const char* desc FC_TASK_NAME_DEFAULT_ARG, priority prio = priority()) -> fc::future<decltype(f())> {
|
||||
return fc::thread::current().schedule( fc::forward<Functor>(f), t, desc, prio );
|
||||
return fc::thread::current().schedule( std::forward<Functor>(f), t, desc, prio );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -25,9 +25,6 @@ namespace fc {
|
|||
template<typename T> struct deduce<T&&> { typedef T type; };
|
||||
template<typename T> struct deduce<const T&&>{ typedef T type; };
|
||||
|
||||
template<typename T, typename U>
|
||||
inline T&& forward( U&& u ) { return static_cast<T&&>(u); }
|
||||
|
||||
struct true_type { enum _value { value = 1 }; };
|
||||
struct false_type { enum _value { value = 0 }; };
|
||||
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ namespace fc
|
|||
template<typename T>
|
||||
variant& operator=( T&& v )
|
||||
{
|
||||
return *this = variant( fc::forward<T>(v) );
|
||||
return *this = variant( std::forward<T>(v) );
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ namespace fc
|
|||
variant_object( string key, T&& val )
|
||||
:_key_value( std::make_shared<std::vector<entry> >() )
|
||||
{
|
||||
*this = variant_object( std::move(key), variant(forward<T>(val)) );
|
||||
*this = variant_object( std::move(key), variant(std::forward<T>(val)) );
|
||||
}
|
||||
variant_object( const variant_object& );
|
||||
variant_object( variant_object&& );
|
||||
|
|
@ -173,7 +173,7 @@ namespace fc
|
|||
mutable_variant_object& operator()( string key, T&& var, uint32_t max_depth )
|
||||
{
|
||||
_FC_ASSERT( max_depth > 0, "Recursion depth exceeded!" );
|
||||
set( std::move(key), variant( fc::forward<T>(var), max_depth - 1 ) );
|
||||
set( std::move(key), variant( std::forward<T>(var), max_depth - 1 ) );
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
|
|
@ -191,7 +191,7 @@ namespace fc
|
|||
explicit mutable_variant_object( T&& v )
|
||||
:_key_value( new std::vector<entry>() )
|
||||
{
|
||||
*this = variant(fc::forward<T>(v)).get_object();
|
||||
*this = variant(std::forward<T>(v)).get_object();
|
||||
}
|
||||
|
||||
mutable_variant_object();
|
||||
|
|
@ -202,7 +202,7 @@ namespace fc
|
|||
mutable_variant_object( string key, T&& val )
|
||||
:_key_value( new std::vector<entry>() )
|
||||
{
|
||||
set( std::move(key), variant(forward<T>(val)) );
|
||||
set( std::move(key), variant(std::forward<T>(val)) );
|
||||
}
|
||||
|
||||
mutable_variant_object( mutable_variant_object&& );
|
||||
|
|
@ -232,7 +232,7 @@ namespace fc
|
|||
optional<variant> v;
|
||||
try
|
||||
{
|
||||
v = variant( fc::forward<T>(var), _max_depth );
|
||||
v = variant( std::forward<T>(var), _max_depth );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue