Updates from BitShares FC #22

Closed
nathanielhourt wants to merge 693 commits from dapp-support into latest-fc
8 changed files with 29 additions and 34 deletions
Showing only changes of commit a8337ecc42 - Show all commits

View file

@ -31,7 +31,7 @@
namespace fc {
static const std::size_t bits_per_char = 0x08; // 8 bits in 1 char(unsigned)
static constexpr std::size_t bits_per_char = 0x08; // 8 bits in 1 char(unsigned)
static const unsigned char bit_mask[bits_per_char] = {
0x01, //00000001
0x02, //00000010

View file

@ -18,7 +18,7 @@ class ripemd160
explicit operator string()const;
char* data()const;
size_t data_size()const { return 160/8; }
constexpr size_t data_size()const { return 160/8; }
static ripemd160 hash( const fc::sha512& h );
static ripemd160 hash( const fc::sha256& h );

View file

@ -17,7 +17,7 @@ class sha1
operator std::string()const;
char* data()const;
size_t data_size()const { return 20; }
constexpr size_t data_size()const { return 20; }
static sha1 hash( const char* d, uint32_t dlen );
static sha1 hash( const std::string& );

View file

@ -16,7 +16,7 @@ class sha224
operator string()const;
char* data()const;
size_t data_size()const { return 224 / 8; }
constexpr size_t data_size()const { return 224 / 8; }
static sha224 hash( const char* d, uint32_t dlen );
static sha224 hash( const string& );

View file

@ -18,7 +18,7 @@ class sha256
operator string()const;
char* data()const;
size_t data_size()const { return 256 / 8; }
constexpr size_t data_size()const { return 256 / 8; }
static sha256 hash( const char* d, uint32_t dlen );
static sha256 hash( const string& );

View file

@ -16,7 +16,7 @@ class sha512
operator std::string()const;
char* data()const;
size_t data_size()const { return 512 / 8; }
constexpr size_t data_size()const { return 512 / 8; }
static sha512 hash( const char* d, uint32_t dlen );
static sha512 hash( const std::string& );

View file

@ -26,11 +26,11 @@ namespace fc {
safe(){}
safe( const safe& o ):value(o.value){}
static safe min()
static constexpr safe min()
{
return std::numeric_limits<T>::min();
}
static safe max()
static constexpr safe max()
{
return std::numeric_limits<T>::max();
}
@ -91,7 +91,7 @@ namespace fc {
safe operator - ()const
{
if( value == std::numeric_limits<T>::min() ) FC_CAPTURE_AND_THROW( overflow_exception, (*this) );
if( value == min() ) FC_CAPTURE_AND_THROW( overflow_exception, (*this) );
return safe( -value );
}

View file

@ -141,58 +141,53 @@ struct storage_ops<N> {
template<typename X>
struct position<X> {
static const int pos = -1;
static constexpr int pos = -1;
};
template<typename X, typename... Ts>
struct position<X, X, Ts...> {
static const int pos = 0;
static constexpr int pos = 0;
};
template<typename X, typename T, typename... Ts>
struct position<X, T, Ts...> {
static const int pos = position<X, Ts...>::pos != -1 ? position<X, Ts...>::pos + 1 : -1;
static constexpr int pos = position<X, Ts...>::pos != -1 ? position<X, Ts...>::pos + 1 : -1;
};
template<typename T, typename... Ts>
struct type_info<T&, Ts...> {
static const bool no_reference_types = false;
static const bool no_duplicates = position<T, Ts...>::pos == -1 && type_info<Ts...>::no_duplicates;
static const size_t size = type_info<Ts...>::size > sizeof(T&) ? type_info<Ts...>::size : sizeof(T&);
static const size_t count = 1 + type_info<Ts...>::count;
static constexpr bool no_reference_types = false;
static constexpr bool no_duplicates = position<T, Ts...>::pos == -1 && type_info<Ts...>::no_duplicates;
static constexpr size_t size = type_info<Ts...>::size > sizeof(T&) ? type_info<Ts...>::size : sizeof(T&);
static constexpr size_t count = 1 + type_info<Ts...>::count;
};
template<typename T, typename... Ts>
struct type_info<T, Ts...> {
static const bool no_reference_types = type_info<Ts...>::no_reference_types;
static const bool no_duplicates = position<T, Ts...>::pos == -1 && type_info<Ts...>::no_duplicates;
static const size_t size = type_info<Ts...>::size > sizeof(T) ? type_info<Ts...>::size : sizeof(T&);
static const size_t count = 1 + type_info<Ts...>::count;
static constexpr bool no_reference_types = type_info<Ts...>::no_reference_types;
static constexpr bool no_duplicates = position<T, Ts...>::pos == -1 && type_info<Ts...>::no_duplicates;
static constexpr size_t size = type_info<Ts...>::size > sizeof(T) ? type_info<Ts...>::size : sizeof(T&);
static constexpr size_t count = 1 + type_info<Ts...>::count;
};
template<>
struct type_info<> {
static const bool no_reference_types = true;
static const bool no_duplicates = true;
static const size_t count = 0;
static const size_t size = 0;
static constexpr bool no_reference_types = true;
static constexpr bool no_duplicates = true;
static constexpr size_t count = 0;
static constexpr size_t size = 0;
};
template<typename TTag>
size_t size( TTag )
constexpr size_t size( TTag )
{
return 0;
}
template<typename TTag, typename A, typename...Ts>
size_t size( TTag tag )
constexpr size_t size( TTag tag )
{
if (tag <= 0)
{
return sizeof(A);
}
return size<TTag, Ts...>( --tag );
return tag <= 0 ? sizeof(A) : size<TTag, Ts...>( --tag );
}
@ -304,7 +299,7 @@ public:
template<typename X, typename = type_in_typelist<X>>
struct tag
{
static const int value = impl::position<X, Types...>::pos;
static constexpr int value = impl::position<X, Types...>::pos;
};
static_variant()
@ -434,7 +429,7 @@ public:
return wrappers[tag]( v, data );
}
static int count() { return impl::type_info<Types...>::count; }
static constexpr int count() { return impl::type_info<Types...>::count; }
void set_which( tag_type w ) {
FC_ASSERT( w >= 0 );
FC_ASSERT( w < count() );