don't specialize standard type trait is_integral
Concerning type traits, the C++ standard states: "The behavior of a program that adds specializations for any of the templates defined in this subclause is undefined unless otherwise specified." There is no exception for is_integral.
This commit is contained in:
parent
5f758b8531
commit
8fdba2aa39
|
@ -54,8 +54,7 @@ namespace libtorrent { namespace aux {
|
||||||
}
|
}
|
||||||
|
|
||||||
// in C++ 17 you can use std::clamp
|
// in C++ 17 you can use std::clamp
|
||||||
template <class T, typename Cond = typename std::enable_if<
|
template <class T>
|
||||||
std::is_integral<T>::value>::type>
|
|
||||||
T clamp(T v, T lo, T hi)
|
T clamp(T v, T lo, T hi)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(lo <= hi);
|
TORRENT_ASSERT(lo <= hi);
|
||||||
|
|
|
@ -135,10 +135,6 @@ namespace libtorrent { namespace aux {
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
|
|
||||||
template<typename UnderlyingType, typename Tag>
|
|
||||||
struct is_integral<libtorrent::aux::strong_typedef<UnderlyingType, Tag>>
|
|
||||||
: std::is_integral<UnderlyingType> {};
|
|
||||||
|
|
||||||
template<typename UnderlyingType, typename Tag>
|
template<typename UnderlyingType, typename Tag>
|
||||||
class numeric_limits<libtorrent::aux::strong_typedef<UnderlyingType, Tag>> : public std::numeric_limits<UnderlyingType>
|
class numeric_limits<libtorrent::aux::strong_typedef<UnderlyingType, Tag>> : public std::numeric_limits<UnderlyingType>
|
||||||
{
|
{
|
||||||
|
|
|
@ -4900,7 +4900,7 @@ bool is_downloading_state(int const st)
|
||||||
bool const was_finished = is_finished();
|
bool const was_finished = is_finished();
|
||||||
for (auto const& p : pieces)
|
for (auto const& p : pieces)
|
||||||
{
|
{
|
||||||
static_assert(std::is_unsigned<decltype(p.second)>::value
|
static_assert(std::is_unsigned<decltype(p.second)::underlying_type>::value
|
||||||
, "we need assert p.second >= dont_download");
|
, "we need assert p.second >= dont_download");
|
||||||
TORRENT_ASSERT(p.second <= top_priority);
|
TORRENT_ASSERT(p.second <= top_priority);
|
||||||
TORRENT_ASSERT(p.first >= piece_index_t(0));
|
TORRENT_ASSERT(p.first >= piece_index_t(0));
|
||||||
|
@ -4910,7 +4910,7 @@ bool is_downloading_state(int const st)
|
||||||
|| p.first >= m_torrent_file->end_piece()
|
|| p.first >= m_torrent_file->end_piece()
|
||||||
|| p.second > top_priority)
|
|| p.second > top_priority)
|
||||||
{
|
{
|
||||||
static_assert(std::is_unsigned<decltype(p.second)>::value
|
static_assert(std::is_unsigned<decltype(p.second)::underlying_type>::value
|
||||||
, "we need additional condition: p.second < dont_download");
|
, "we need additional condition: p.second < dont_download");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -4953,7 +4953,7 @@ bool is_downloading_state(int const st)
|
||||||
bool const was_finished = is_finished();
|
bool const was_finished = is_finished();
|
||||||
for (auto prio : pieces)
|
for (auto prio : pieces)
|
||||||
{
|
{
|
||||||
static_assert(std::is_unsigned<decltype(prio)>::value
|
static_assert(std::is_unsigned<decltype(prio)::underlying_type>::value
|
||||||
, "we need assert prio >= dont_download");
|
, "we need assert prio >= dont_download");
|
||||||
TORRENT_ASSERT(prio <= top_priority);
|
TORRENT_ASSERT(prio <= top_priority);
|
||||||
filter_updated |= m_picker->set_piece_priority(index, prio);
|
filter_updated |= m_picker->set_piece_priority(index, prio);
|
||||||
|
|
Loading…
Reference in New Issue