mark all converstion to bool operators as explicit

This commit is contained in:
Steven Siloti 2016-12-11 15:44:52 -08:00 committed by Arvid Norberg
parent d9f8d4b642
commit ca07ee83a3
10 changed files with 17 additions and 17 deletions

View File

@ -280,7 +280,7 @@ struct TORRENT_EXPORT bdecode_node
type_t type() const;
// returns true if type() != none_t.
operator bool() const;
explicit operator bool() const;
// return a non-owning reference to this node. This is useful to refer to
// the root node without copying it in assignments.

View File

@ -59,7 +59,7 @@ namespace libtorrent
m_ptr = p.m_ptr;
p.m_ptr = tmp;
}
operator bool() const { return m_ptr != 0; }
explicit operator bool() const { return m_ptr != 0; }
~copy_ptr() { delete m_ptr; }
private:
T* m_ptr;

View File

@ -502,7 +502,7 @@ namespace libtorrent
storage_error(): file(-1), operation(0) {}
explicit storage_error(error_code e): ec(e), file(-1), operation(0) {}
operator bool() const { return ec.value() != 0; }
explicit operator bool() const { return ec.value() != 0; }
// the error that occurred
error_code ec;

View File

@ -219,7 +219,7 @@ namespace libtorrent
file const& operator*() const;
file* get();
file const* get() const;
operator bool() const;
explicit operator bool() const;
file_handle& reset(file* f = nullptr);
char stack[2048];

View File

@ -394,7 +394,7 @@ namespace libtorrent
// extract ip
i = info.dict_find_string("ip");
if (i == 0)
if (!i)
{
ec = errors::invalid_tracker_response;
return false;
@ -403,7 +403,7 @@ namespace libtorrent
// extract port
i = info.dict_find_int("port");
if (i == 0)
if (!i)
{
ec = errors::invalid_tracker_response;
return false;

View File

@ -140,10 +140,12 @@ item::item(entry v)
{}
item::item(bdecode_node const& v)
: m_value(std::move(v))
, m_seq(0)
: m_seq(0)
, m_mutable(false)
{}
{
// TODO: implement ctor for entry from bdecode_node?
m_value = v;
}
item::item(entry v, span<char const> salt
, sequence_number const seq, public_key const& pk, secret_key const& sk)

View File

@ -73,7 +73,7 @@ bool verify_message_impl(bdecode_node const& message, span<key_desc_t const> des
// none_t means any type
if (ret[i] && ret[i].type() != k.type && k.type != bdecode_node::none_t)
ret[i].clear();
if (ret[i] == 0 && (k.flags & key_desc_t::optional) == 0)
if (!ret[i] && (k.flags & key_desc_t::optional) == 0)
{
// the key was not found, and it's not an optional key
std::snprintf(error.data(), error.size(), "missing '%s' key", k.name);

View File

@ -1336,7 +1336,7 @@ namespace libtorrent
}
bdecode_node info = torrent_file.dict_find_dict("info");
if (info == 0)
if (!info)
{
bdecode_node link = torrent_file.dict_find_string("magnet-uri");
if (link)

View File

@ -360,7 +360,7 @@ namespace libtorrent { namespace
#ifndef TORRENT_DISABLE_LOGGING
if (p6) num_dropped += p6.string_length() / 18;
#endif
if (p6 != 0 && p6.type() == bdecode_node::string_t)
if (p6.type() == bdecode_node::string_t)
{
int const num_peers = p6.string_length() / 18;
char const* in = p6.string_ptr();
@ -379,9 +379,7 @@ namespace libtorrent { namespace
if (p6) num_added += p6.string_length() / 18;
#endif
bdecode_node p6f = pex_msg.dict_find("added6.f");
if (p6 != 0
&& p6f != 0
&& p6.type() == bdecode_node::string_t
if (p6.type() == bdecode_node::string_t
&& p6f.type() == bdecode_node::string_t
&& p6f.string_length() == p6.string_length() / 18)
{

View File

@ -199,8 +199,8 @@ TORRENT_TEST(magnet)
std::printf("session_state\n%s\n", print_entry(session_state2).c_str());
// make sure settings that haven't been changed from their defaults are not saved
TEST_CHECK(session_state2.dict_find("settings")
.dict_find("optimistic_disk_retry") == 0);
TEST_CHECK(!session_state2.dict_find("settings")
.dict_find("optimistic_disk_retry"));
s->load_state(session_state2);