Skip to content

Commit

Permalink
Fix narrowing
Browse files Browse the repository at this point in the history
  • Loading branch information
frederick-vs-ja committed Oct 3, 2023
1 parent 82b7967 commit 088b367
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions stl/inc/random
Original file line number Diff line number Diff line change
Expand Up @@ -1519,12 +1519,13 @@ private:

_EXPORT_STD template <class _Engine, size_t _Px, size_t _Rx>
class discard_block_engine // discard_block_engine compound engine
: public conditional_t<_Px <= INT_MAX, discard_block<_Engine, _Px, _Rx>, _Discard_block_base<_Engine, _Px, _Rx>> {
: public conditional_t<_Px <= INT_MAX, discard_block<_Engine, static_cast<int>(_Px), static_cast<int>(_Rx)>,
_Discard_block_base<_Engine, _Px, _Rx>> {
public:
static_assert(0 < _Rx && _Rx <= _Px, "invalid template argument for discard_block_engine");

using _Mybase =
conditional_t<_Px <= INT_MAX, discard_block<_Engine, _Px, _Rx>, _Discard_block_base<_Engine, _Px, _Rx>>;
using _Mybase = conditional_t<_Px <= INT_MAX, discard_block<_Engine, static_cast<int>(_Px), static_cast<int>(_Rx)>,
_Discard_block_base<_Engine, _Px, _Rx>>;
using result_type = typename _Engine::result_type;

static constexpr size_t block_size = _Px;
Expand Down
2 changes: 1 addition & 1 deletion tests/tr1/tests/random4/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static void tsubtract() {
}

static void tdiscard() {
int i;
STD size_t i;
typedef STD subtract_with_carry_engine<Uint32, 24, 10, 24> rng_base_t;
typedef STD discard_block_engine<rng_base_t, 223, 24> rng_t;
CHECK_INT(rng_t::block_size, 223);
Expand Down

0 comments on commit 088b367

Please sign in to comment.