Skip to content

Commit 166f0de

Browse files
committed
Fix another warning from MSVC
1 parent 4f196a7 commit 166f0de

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

include/tao/json/stream.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <iomanip>
88
#include <iosfwd>
9+
#include <stdexcept>
910

1011
#include "to_stream.hpp"
1112
#include "value.hpp"
@@ -19,9 +20,12 @@ namespace tao
1920
template< template< typename... > class Traits >
2021
std::ostream& operator<<( std::ostream& o, const basic_value< Traits >& v )
2122
{
22-
const std::uint64_t w = o.width( 0 );
23+
const auto w = o.width( 0 );
2324
if( w > 0 ) {
24-
json::to_stream( o, v, w );
25+
if( static_cast< std::uint64_t >( w ) > static_cast< std::uint64_t >( std::numeric_limits< std::size_t >::max() ) ) {
26+
throw std::runtime_error( "indentation too large" );
27+
}
28+
json::to_stream( o, v, static_cast< std::size_t >( w ) );
2529
}
2630
else {
2731
json::to_stream( o, v );

0 commit comments

Comments
 (0)