Skip to content

Commit 03697b0

Browse files
committed
Make _binary compatible with C++11
1 parent 05f7422 commit 03697b0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

include/tao/json/binary.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#ifndef TAOCPP_JSON_INCLUDE_BINARY_HPP
55
#define TAOCPP_JSON_INCLUDE_BINARY_HPP
66

7+
#include <initializer_list>
78
#include <vector>
89

910
#include "byte.hpp"
@@ -15,16 +16,15 @@ namespace tao
1516
{
1617
namespace internal
1718
{
18-
constexpr char unhex( const char c ) noexcept
19+
constexpr char unhex_char( const char c ) noexcept
1920
{
2021
return ( c < 'A' ) ? ( c - '0' ) : ( ( c < 'a' ) ? ( c - 'A' + 10 ) : ( c - 'a' + 10 ) );
2122
}
2223

2324
template< typename T, typename V, char... Cs, std::size_t... Is >
24-
constexpr T unhex( index_sequence< Is... > )
25+
constexpr T unhex( index_sequence< Is... >, std::initializer_list< char > a )
2526
{
26-
const char a[] = { unhex( Cs )... };
27-
return T{ V( ( a[ 2 * Is ] << 4 ) + a[ 2 * Is + 1 ] )... };
27+
return T{ V( ( a.begin()[ 2 * Is ] << 4 ) + a.begin()[ 2 * Is + 1 ] )... };
2828
}
2929

3030
template< typename T, typename V, char C0, char C1, char... Cs >
@@ -33,7 +33,7 @@ namespace tao
3333
static_assert( C0 == '0', "not a hex literal" );
3434
static_assert( C1 == 'x' || C1 == 'X', "not a hex literal" );
3535
static_assert( sizeof...( Cs ) % 2 == 0, "invalid number of hexadecimal digits" );
36-
return unhex< T, V, Cs... >( make_index_sequence< sizeof...( Cs ) / 2 >() );
36+
return unhex< T, V, Cs... >( make_index_sequence< sizeof...( Cs ) / 2 >(), { unhex_char( Cs )... } );
3737
}
3838

3939
} // namespace internal

0 commit comments

Comments
 (0)