/* * Copyright (c) 2019 BitShares Blockchain Foundation, and contributors * * The MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #pragma once #include namespace fc { template< typename T, size_t N > class zero_initialized_array; template< size_t N > class zero_initialized_array< unsigned char, N > : public std::array< unsigned char, N > { public: zero_initialized_array() : std::array< unsigned char, N >() { } }; template struct get_typename< zero_initialized_array > { static const char* name() { static std::string _name = std::string("zero_initialized_array<") + std::string(fc::get_typename::name()) + "," + fc::to_string(N) + ">"; return _name.c_str(); } }; class variant; template void to_variant( const zero_initialized_array& bi, variant& v, uint32_t max_depth = 1 ) { to_variant( static_cast&>( bi ), v, max_depth ); } template void from_variant( const variant& v, zero_initialized_array& bi, uint32_t max_depth = 1 ) { from_variant( v, static_cast&>( bi ), max_depth ); } namespace raw { template inline void pack( Stream& s, const zero_initialized_array& v, uint32_t _max_depth ) { pack( s, static_cast&>( v ), _max_depth ); } template inline void unpack( Stream& s, zero_initialized_array& v, uint32_t _max_depth ) { try { unpack( s, static_cast&>( v ), _max_depth ); } FC_RETHROW_EXCEPTIONS( warn, "zero_initialized_array", ("length",N) ) } } } namespace std { #if defined(__clang__) // Fix: https://github.com/bitshares/bitshares-core/issues/2197 #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wmismatched-tags" #endif template< typename T, size_t N > class tuple_size< fc::zero_initialized_array< T, N > > : public tuple_size< array< T, N > > {}; #if defined(__clang__) #pragma clang diagnostic pop #endif }