__cplusplus cleanup (#951)

cleanup
This commit is contained in:
Alden Torres 2016-07-26 18:30:19 -04:00 committed by Arvid Norberg
parent 634c2bce60
commit 7caa99d6f1
12 changed files with 4 additions and 192 deletions

View File

@ -11,15 +11,12 @@ struct bytes
{
bytes(char const* s, int len): arr(s, len) {}
bytes(std::string const& s): arr(s) {}
#if __cplusplus >= 201103L
bytes(std::string&& s): arr(std::move(s)) {}
bytes(bytes const&) = default;
bytes(bytes&&) = default;
bytes& operator=(bytes&&) = default;
#endif
bytes() {}
std::string arr;
};
#endif

View File

@ -54,10 +54,8 @@ namespace libtorrent
announce_entry(std::string const& u);
announce_entry();
~announce_entry();
#if __cplusplus >= 201103L
announce_entry(announce_entry const&) = default;
announce_entry& operator=(announce_entry const&) = default;
#endif
// tracker URL as it appeared in the torrent file
std::string url;
@ -195,4 +193,3 @@ namespace libtorrent
}
#endif

View File

@ -172,10 +172,8 @@ namespace libtorrent
{
cached_piece_entry();
~cached_piece_entry();
#if __cplusplus >= 201103L
cached_piece_entry(cached_piece_entry const&) = default;
cached_piece_entry& operator=(cached_piece_entry const&) = default;
#endif
bool ok_to_evict(bool ignore_hash = false) const
{
@ -545,4 +543,3 @@ namespace libtorrent
}
#endif // TORRENT_BLOCK_CACHE

View File

@ -117,7 +117,7 @@ namespace libtorrent
// newly constructed entry
entry(dictionary_type);
entry(span<char const>);
template <typename U, typename = typename std::enable_if<
template <typename U, typename Cond = typename std::enable_if<
std::is_same<U, entry::string_type>::value
|| std::is_same<U, char const*>::value>::type>
entry(U v)
@ -161,7 +161,7 @@ namespace libtorrent
entry& operator=(entry&&);
entry& operator=(dictionary_type);
entry& operator=(span<char const>);
template <typename U, typename = typename std::enable_if<
template <typename U, typename Cond = typename std::enable_if<
std::is_same<U, entry::string_type>::value
|| std::is_same<U, char const*>::value>::type>
entry& operator=(U v)

View File

@ -56,10 +56,8 @@ namespace libtorrent
file_entry();
// hidden
~file_entry();
#if __cplusplus >= 201103L
file_entry(file_entry const&) = default;
file_entry& operator=(file_entry const&) = default;
#endif
// the full path of this file. The paths are unicode strings
// encoded in UTF-8.
@ -648,4 +646,3 @@ namespace libtorrent
}
#endif // TORRENT_FILE_STORAGE_HPP_INCLUDED

View File

@ -142,9 +142,7 @@ namespace libtorrent
struct has_block
{
#if __cplusplus >= 201103L
has_block(has_block const&) = default;
#endif
has_block(piece_block const& b): block(b) {}
piece_block const& block;

View File

@ -59,10 +59,8 @@ namespace libtorrent
session_settings(std::string const& user_agent = "libtorrent/"
LIBTORRENT_VERSION);
~session_settings();
#if __cplusplus >= 201103L
session_settings(session_settings const&) = default;
session_settings& operator=(session_settings const&) = default;
#endif
// automatically set to the libtorrent version you're using in order to
// be forward binary compatible. This field should not be changed.

View File

@ -78,7 +78,7 @@ namespace libtorrent
reverse_iterator rend() const { return reverse_iterator(begin()); }
T& front() const { TORRENT_ASSERT(m_len > 0); return m_ptr[0]; }
T& back() const { TORRENT_ASSERT(m_len > 0); return m_ptr[m_len-1]; }
T& back() const { TORRENT_ASSERT(m_len > 0); return m_ptr[m_len - 1]; }
span<T> first(size_t const n) const
{

View File

@ -53,10 +53,8 @@ namespace libtorrent
// hidden
torrent_status();
~torrent_status();
#if __cplusplus >= 201103L
torrent_status(torrent_status const&) = default;
torrent_status& operator=(torrent_status const&) = default;
#endif
// compares if the torrent status objects come from the same torrent. i.e.
// only the torrent_handle field is compared.
@ -518,5 +516,4 @@ namespace libtorrent
}
#endif
#endif // TORRENT_TORRENT_STATUS_HPP_INCLUDED

View File

@ -296,10 +296,8 @@ private:
TORRENT_ASSERT(magic == 1337);
magic = 0;
}
#if __cplusplus >= 201103L
rootdevice(rootdevice const&) = default;
rootdevice& operator=(rootdevice const&) = default;
#endif
#endif
// the interface url, through which the list of
@ -418,4 +416,3 @@ namespace boost { namespace system {
} }
#endif

View File

@ -1,162 +0,0 @@
/*
Copyright (c) 2008-2015, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.hpp"
#ifndef TORRENT_NO_DEPRECATE
#include "setup_swarm.hpp"
#include "libtorrent/alert.hpp"
#include "libtorrent/announce_entry.hpp"
#include "libtorrent/settings_pack.hpp"
#include "libtorrent/add_torrent_params.hpp"
#include "libtorrent/alert_types.hpp"
#include "libtorrent/extensions/lt_trackers.hpp"
#include "libtorrent/session.hpp"
#include "settings.hpp"
using namespace libtorrent;
TORRENT_TEST(plain)
{
dsl_config network_cfg;
sim::simulation sim{network_cfg};
settings_pack pack = settings();
add_torrent_params p;
p.flags &= ~lt::add_torrent_params::flag_paused;
p.flags &= ~lt::add_torrent_params::flag_auto_managed;
// the default torrent has one tracker
// we remove this from session 0 (the one under test)
p.trackers.push_back("http://test.non-existent.com/announce");
bool connected = false;
setup_swarm(2, swarm_test::upload
, sim , pack, p
// init session
, [](lt::session& ses) {
ses.add_extension(&create_lt_trackers_plugin);
}
// add session
, [](lt::settings_pack& pack) {}
// add torrent
, [](lt::add_torrent_params& params) {
// make sure neither peer has any content
// TODO: it would be more efficient to not create the content in the first
// place
params.save_path = save_path(test_counter(), 1);
// the test is whether this peer will receive the tracker or not
params.trackers.clear();
}
// on alert
, [&](lt::alert const* a, lt::session& ses) {
if (alert_cast<lt::peer_connect_alert>(a))
connected = true;
}
// terminate
, [&](int ticks, lt::session& ses) -> bool {
if (ticks > 10)
{
TEST_ERROR("timeout");
return true;
}
return connected && ses.get_torrents()[0].trackers().size() > 0;
});
TEST_EQUAL(connected, true);
}
TORRENT_TEST(no_metadata)
{
dsl_config network_cfg;
sim::simulation sim{network_cfg};
settings_pack pack = settings();
add_torrent_params p;
p.flags &= ~lt::add_torrent_params::flag_paused;
p.flags &= ~lt::add_torrent_params::flag_auto_managed;
// the default torrent has one tracker
// we remove this from session 0 (the one under test)
p.trackers.push_back("http://test.non-existent.com/announce");
bool connected = false;
setup_swarm(2, swarm_test::upload
, sim , pack, p
// init session
, [](lt::session& ses) {
ses.add_extension(&create_lt_trackers_plugin);
}
// add session
, [](lt::settings_pack& pack) {}
// add torrent
, [](lt::add_torrent_params& params) {
// make sure neither peer has any content
// TODO: it would be more efficient to not create the content in the first
// place
params.save_path = save_path(test_counter(), 1);
// the test is whether this peer will receive the tracker or not
params.trackers.clear();
// if we don't have metadata, the other peer should not send the
// tracker to us
params.info_hash = sha1_hash("aaaaaaaaaaaaaaaaaaaa");
params.ti.reset();
}
// on alert
, [&](lt::alert const* a, lt::session& ses) {
if (alert_cast<lt::peer_connect_alert>(a))
connected = true;
}
// terminate
, [](int ticks, lt::session& ses) -> bool {
if (ticks < 10)
return false;
TEST_EQUAL(ses.get_torrents()[0].trackers().size(), 0);
return true;
});
TEST_EQUAL(connected, true);
}
#else
TORRENT_TEST(dummy) {}
#endif

View File

@ -96,7 +96,6 @@ struct F
TEST_EQUAL(f_.gutted, false);
}
#if __cplusplus >= 201103L
F(F&& f_)
: self(this)
, f(f_.f)
@ -109,7 +108,6 @@ struct F
TEST_EQUAL(f_.gutted, false);
f_.gutted = true;
}
#endif
~F()
{
@ -296,5 +294,3 @@ TORRENT_TEST(nontrivial)
q.emplace_back<E>("testing to allocate non-trivial objects");
}
}