summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2019-01-17 19:35:11 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2019-02-12 21:10:48 +0000
commit854abea18ca1a46c69b2eed1698839db36b5deb7 (patch)
tree47d4d9bccc3b928bde2c549e65ff066833bba580
parentEnable some clang-tidy checks and fix up accordingly (diff)
downloadlibadhocutil-854abea18ca1a46c69b2eed1698839db36b5deb7.tar.bz2
libadhocutil-854abea18ca1a46c69b2eed1698839db36b5deb7.tar.xz
libadhocutil-854abea18ca1a46c69b2eed1698839db36b5deb7.zip
More clang-tidy WIP
-rw-r--r--Jamroot.jam4
-rw-r--r--libadhocutil/Jamfile.jam3
-rw-r--r--libadhocutil/buffer.cpp24
-rw-r--r--libadhocutil/buffer.h2
-rw-r--r--libadhocutil/compileTimeFormatter.h6
-rw-r--r--libadhocutil/curlHandle.cpp2
-rw-r--r--libadhocutil/curlMultiHandle.cpp14
-rw-r--r--libadhocutil/curlStream.cpp4
-rw-r--r--libadhocutil/exception.h6
-rw-r--r--libadhocutil/fileUtils.cpp2
-rw-r--r--libadhocutil/fprintbf.cpp2
-rw-r--r--libadhocutil/lexer-regex.cpp2
-rw-r--r--libadhocutil/lexer.cpp6
-rw-r--r--libadhocutil/lexer.h2
-rw-r--r--libadhocutil/plugins.cpp4
-rw-r--r--libadhocutil/processPipes.cpp6
-rw-r--r--libadhocutil/resourcePool.cpp4
-rw-r--r--libadhocutil/runtimeContext.cpp4
-rw-r--r--libadhocutil/scopeExit.cpp4
-rw-r--r--libadhocutil/unittests/testCache.cpp20
-rw-r--r--libadhocutil/unittests/testCompileTimeFormatter.cpp6
-rw-r--r--libadhocutil/unittests/testException.cpp6
-rw-r--r--libadhocutil/unittests/testFactory.cpp6
-rw-r--r--libadhocutil/unittests/testLazyPointer.cpp4
-rw-r--r--libadhocutil/unittests/testResourcePool.cpp3
-rw-r--r--libadhocutil/uriParse.cpp9
-rw-r--r--libadhocutil/uriParse.h4
27 files changed, 72 insertions, 87 deletions
diff --git a/Jamroot.jam b/Jamroot.jam
index 6c48dae..7111626 100644
--- a/Jamroot.jam
+++ b/Jamroot.jam
@@ -21,6 +21,10 @@ project
<toolset>tidy:<checkxx>bugprone-*
<toolset>tidy:<checkxx>clang-*
<toolset>tidy:<checkxx>misc-*
+ <toolset>tidy:<checkxx>modernize-*
+#<toolset>tidy:<checkxx>cppcoreguidelines-*
+#<toolset>tidy:<checkxx>hicpp-*
+#<toolset>tidy:<checkxx>performance-*
;
build-project libadhocutil ;
diff --git a/libadhocutil/Jamfile.jam b/libadhocutil/Jamfile.jam
index 3bbd3df..a8898c0 100644
--- a/libadhocutil/Jamfile.jam
+++ b/libadhocutil/Jamfile.jam
@@ -8,8 +8,7 @@ lib curl ;
lib dl ;
lib adhocutil :
- [ glob *.cpp *.ice : bin ]
- [ obj nvpParse : nvpParse.ll : <include>. <toolset>tidy:<checker>none ]
+ [ glob *.cpp *.ice *.ll : bin ]
:
<include>.
<library>Ice++11
diff --git a/libadhocutil/buffer.cpp b/libadhocutil/buffer.cpp
index f0deedc..2741c4a 100644
--- a/libadhocutil/buffer.cpp
+++ b/libadhocutil/buffer.cpp
@@ -1,6 +1,6 @@
#include "buffer.h"
-#include <string.h>
-#include <stdio.h>
+#include <cstring>
+#include <cstdio>
namespace AdHoc {
@@ -73,8 +73,8 @@ Buffer::CStringFragment::str() const
// Std::String Fragment
//
-Buffer::StringFragment::StringFragment(const std::string & str) :
- buf(str)
+Buffer::StringFragment::StringFragment(const std::string str) :
+ buf(std::move(str))
{
}
@@ -106,9 +106,7 @@ Buffer::StringFragment::operator[](size_t x) const
// Buffer :)
//
-Buffer::Buffer()
-{
-}
+Buffer::Buffer() = default;
Buffer::Buffer(const char * src, CStringHandling h)
{
@@ -125,9 +123,7 @@ Buffer::Buffer(const std::string & str)
append(str);
}
-Buffer::~Buffer()
-{
-}
+Buffer::~Buffer() = default;
Buffer &
Buffer::append(const char * str, CStringHandling h)
@@ -213,7 +209,7 @@ Buffer::getFormat(const std::string & msgfmt)
void
Buffer::writeto(char * buf, size_t bufSize, size_t off) const
{
- Content::const_iterator f = content.begin();
+ auto f = content.begin();
while (f != content.end() && (*f)->length() < off) {
off -= (*f)->length();
++f;
@@ -291,11 +287,7 @@ Buffer::operator=(const std::string & str)
}
Buffer &
-Buffer::operator=(const Buffer & buf)
-{
- content = buf.content;
- return *this;
-}
+Buffer::operator=(const Buffer & buf) = default;
Buffer::operator bool() const
{
diff --git a/libadhocutil/buffer.h b/libadhocutil/buffer.h
index d553c57..afbb100 100644
--- a/libadhocutil/buffer.h
+++ b/libadhocutil/buffer.h
@@ -145,7 +145,7 @@ class DLL_PUBLIC Buffer {
class DLL_PRIVATE StringFragment : public FragmentBase {
public:
- StringFragment(const std::string &);
+ StringFragment(const std::string);
size_t length() const;
char operator[](size_t) const;
diff --git a/libadhocutil/compileTimeFormatter.h b/libadhocutil/compileTimeFormatter.h
index 9dae0ef..785f255 100644
--- a/libadhocutil/compileTimeFormatter.h
+++ b/libadhocutil/compileTimeFormatter.h
@@ -2,7 +2,7 @@
#define ADHOCUTIL_COMPILE_TIME_FORMATTER_H
#include <sstream>
-#include <string.h>
+#include <cstring>
#include <boost/preprocessor/variadic/size.hpp>
#include "unique.h"
@@ -120,12 +120,12 @@ namespace AdHoc {
template <const auto & S, decltype(strlen<S>()) L = strlen<S>()>
class Formatter {
private:
- typedef decltype(strlen<S>()) strlen_t;
+ using strlen_t = decltype(strlen<S>());
template<const auto &, auto, auto, typename> friend struct StreamWriterBase;
public:
/// The derived charater type of the format string.
- typedef typename std::decay<decltype(*S)>::type char_type;
+ using char_type = typename std::decay<decltype(*S)>::type;
/**
* Get a string containing the result of formatting.
* @param pn the format arguments.
diff --git a/libadhocutil/curlHandle.cpp b/libadhocutil/curlHandle.cpp
index 3f0263b..5be0d38 100644
--- a/libadhocutil/curlHandle.cpp
+++ b/libadhocutil/curlHandle.cpp
@@ -15,7 +15,7 @@ static void cleanup()
CurlHandle::CurlHandle(const std::string & url) :
curl_handle(curl_easy_init()),
curl_headers(nullptr),
- postS(NULL), postE(NULL)
+ postS(nullptr), postE(nullptr)
{
curl_easy_setopt(curl_handle, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl_handle, CURLOPT_FAILONERROR, 1);
diff --git a/libadhocutil/curlMultiHandle.cpp b/libadhocutil/curlMultiHandle.cpp
index cf75032..381979f 100644
--- a/libadhocutil/curlMultiHandle.cpp
+++ b/libadhocutil/curlMultiHandle.cpp
@@ -9,15 +9,15 @@ namespace Net {
class RunningCurl : public CurlStreamSource {
public:
- RunningCurl(const std::string & url, const std::function<void(std::istream &)> & c) :
+ RunningCurl(const std::string & url, const std::function<void(std::istream &)> c) :
CurlStreamSource(url),
- consumer(c)
+ consumer(std::move(c))
{
}
void callback() override
{
- typedef boost::reference_wrapper<RunningCurl> rc_ref;
+ using rc_ref = boost::reference_wrapper<RunningCurl>;
boost::iostreams::stream<rc_ref> curlstrm(std::ref(*this));
consumer(curlstrm);
}
@@ -26,13 +26,9 @@ class RunningCurl : public CurlStreamSource {
const std::function<void(std::istream &)> consumer;
};
-CurlMultiHandle::CurlMultiHandle()
-{
-}
+CurlMultiHandle::CurlMultiHandle() = default;
-CurlMultiHandle::~CurlMultiHandle()
-{
-}
+CurlMultiHandle::~CurlMultiHandle() = default;
CurlHandlePtr
CurlMultiHandle::addCurl(const std::string & url, const std::function<void(std::istream &)> & c)
diff --git a/libadhocutil/curlStream.cpp b/libadhocutil/curlStream.cpp
index d16ff00..69f04f0 100644
--- a/libadhocutil/curlStream.cpp
+++ b/libadhocutil/curlStream.cpp
@@ -13,9 +13,7 @@ CurlStreamSource::CurlStreamSource(const std::string & url) :
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, this);
}
-AdHoc::Net::CurlStreamSource::~CurlStreamSource()
-{
-}
+AdHoc::Net::CurlStreamSource::~CurlStreamSource() = default;
std::streamsize
CurlStreamSource::read(char * target, std::streamsize targetSize)
diff --git a/libadhocutil/exception.h b/libadhocutil/exception.h
index bad9771..92ed65f 100644
--- a/libadhocutil/exception.h
+++ b/libadhocutil/exception.h
@@ -16,7 +16,7 @@ namespace AdHoc {
Exception(const T & ... t) : BaseException(t...) { }
/// Override of std::exception::what() to create text as required.
- inline const char * what() const throw() override
+ inline const char * what() const noexcept override
{
if (!msg) {
msg = message();
@@ -26,10 +26,10 @@ namespace AdHoc {
private:
/// Message text provider.
- virtual std::string message() const throw() = 0;
+ virtual std::string message() const noexcept = 0;
mutable std::optional<std::string> msg;
};
- typedef Exception<std::exception> StdException;
+ using StdException = Exception<std::exception>;
}
#endif
diff --git a/libadhocutil/fileUtils.cpp b/libadhocutil/fileUtils.cpp
index 76d57a8..540990a 100644
--- a/libadhocutil/fileUtils.cpp
+++ b/libadhocutil/fileUtils.cpp
@@ -126,7 +126,7 @@ namespace AdHoc {
void *
MemMap::setupMapInt(int flags) const
{
- return mmap(0, st.st_size, flags & (O_WRONLY | O_RDWR) ? PROT_WRITE : PROT_READ, MAP_SHARED, fh, 0);
+ return mmap(nullptr, st.st_size, flags & (O_WRONLY | O_RDWR) ? PROT_WRITE : PROT_READ, MAP_SHARED, fh, 0);
}
void *
diff --git a/libadhocutil/fprintbf.cpp b/libadhocutil/fprintbf.cpp
index b62ebf0..d46b211 100644
--- a/libadhocutil/fprintbf.cpp
+++ b/libadhocutil/fprintbf.cpp
@@ -1,5 +1,5 @@
#include "fprintbf.h"
-#include <stdio.h>
+#include <cstdio>
#include <system_error>
size_t
diff --git a/libadhocutil/lexer-regex.cpp b/libadhocutil/lexer-regex.cpp
index 493c823..3765285 100644
--- a/libadhocutil/lexer-regex.cpp
+++ b/libadhocutil/lexer-regex.cpp
@@ -16,7 +16,7 @@ namespace AdHoc {
}
}
- ~Regex()
+ ~Regex() override
{
if (err) {
g_error_free(err);
diff --git a/libadhocutil/lexer.cpp b/libadhocutil/lexer.cpp
index 7c25688..6c6505f 100644
--- a/libadhocutil/lexer.cpp
+++ b/libadhocutil/lexer.cpp
@@ -4,11 +4,9 @@
namespace AdHoc {
const Lexer::State Lexer::InitialState = "";
- Lexer::Lexer()
- {
- }
+ Lexer::Lexer() = default;
- Lexer::Lexer(const Rules & r) : rules(r)
+ Lexer::Lexer(const Rules r) : rules(std::move(r))
{
}
diff --git a/libadhocutil/lexer.h b/libadhocutil/lexer.h
index be39525..21c8782 100644
--- a/libadhocutil/lexer.h
+++ b/libadhocutil/lexer.h
@@ -78,7 +78,7 @@ namespace AdHoc {
/// Default constructor (empty rule set)
Lexer();
/// Construct with an initial set of rules.
- Lexer(const Rules &);
+ Lexer(const Rules);
/// The lexer's current rule set.
Rules rules;
diff --git a/libadhocutil/plugins.cpp b/libadhocutil/plugins.cpp
index 4251ba1..34ccae2 100644
--- a/libadhocutil/plugins.cpp
+++ b/libadhocutil/plugins.cpp
@@ -1,5 +1,5 @@
#include "plugins.h"
-#include <string.h>
+#include <cstring>
#include <dlfcn.h>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
@@ -20,7 +20,7 @@ namespace std {
std::ostream &
operator<<(std::ostream & s, const std::type_info & t)
{
- char * buf = __cxxabiv1::__cxa_demangle(t.name(), NULL, NULL, NULL);
+ char * buf = __cxxabiv1::__cxa_demangle(t.name(), nullptr, nullptr, nullptr);
s << buf;
free(buf);
return s;
diff --git a/libadhocutil/processPipes.cpp b/libadhocutil/processPipes.cpp
index 5e243d5..4973f9b 100644
--- a/libadhocutil/processPipes.cpp
+++ b/libadhocutil/processPipes.cpp
@@ -1,7 +1,7 @@
#include "processPipes.h"
#include <unistd.h>
#include <poll.h>
-#include <string.h>
+#include <cstring>
#include <sys/resource.h>
#include <stdexcept>
#include <sys.h>
@@ -17,7 +17,7 @@ pipe(int pipes[2], ScopeExit & tidyUp)
if (::pipe(pipes)) {
throw SystemException("pipe(2) failed", strerror(errno), errno);
}
- tidyUp.onFailure.push_back([pipes] {
+ tidyUp.onFailure.emplace_back([pipes] {
close(pipes[0]);
close(pipes[1]);
});
@@ -78,7 +78,7 @@ ProcessPipes::ProcessPipes(const std::vector<std::string> & args, bool i, bool o
for (const auto & p : args) {
*w++ = strdup(p.c_str());
}
- *w = NULL;
+ *w = nullptr;
if (*buf) {
execv(buf[0], buf);
}
diff --git a/libadhocutil/resourcePool.cpp b/libadhocutil/resourcePool.cpp
index 948e419..0724a81 100644
--- a/libadhocutil/resourcePool.cpp
+++ b/libadhocutil/resourcePool.cpp
@@ -9,7 +9,7 @@ namespace AdHoc {
AdHocFormatter(TimeOutOnResourcePoolMsg, "Timeout getting a resource from pool of %?");
std::string
- TimeOutOnResourcePool::message() const throw()
+ TimeOutOnResourcePool::message() const noexcept
{
return TimeOutOnResourcePoolMsg::get(name);
}
@@ -22,7 +22,7 @@ namespace AdHoc {
AdHocFormatter(NoCurrentResourceMsg, "Thread %? has no current resource handle of type %?");
std::string
- NoCurrentResource::message() const throw()
+ NoCurrentResource::message() const noexcept
{
return NoCurrentResourceMsg::get(threadId, name);
}
diff --git a/libadhocutil/runtimeContext.cpp b/libadhocutil/runtimeContext.cpp
index 46a67f3..7c911a5 100644
--- a/libadhocutil/runtimeContext.cpp
+++ b/libadhocutil/runtimeContext.cpp
@@ -1,6 +1,6 @@
#include "runtimeContext.h"
-#include <errno.h>
-#include <string.h>
+#include <cerrno>
+#include <cstring>
#include <sys.h>
namespace AdHoc {
diff --git a/libadhocutil/scopeExit.cpp b/libadhocutil/scopeExit.cpp
index a108fae..fc48219 100644
--- a/libadhocutil/scopeExit.cpp
+++ b/libadhocutil/scopeExit.cpp
@@ -2,9 +2,7 @@
namespace AdHoc {
-ScopeExit::ScopeExit()
-{
-}
+ScopeExit::ScopeExit() = default;
ScopeExit::ScopeExit(const Event & onexitpre, const Event & onsuccess, const Event & onfailure, const Event & onexitpost)
{
diff --git a/libadhocutil/unittests/testCache.cpp b/libadhocutil/unittests/testCache.cpp
index 5757b71..dc7bd6b 100644
--- a/libadhocutil/unittests/testCache.cpp
+++ b/libadhocutil/unittests/testCache.cpp
@@ -29,7 +29,7 @@ namespace std {
}
namespace AdHoc {
- typedef Cache<Obj, std::string> TestCache;
+ using TestCache = Cache<Obj, std::string>;
template class Cache<Obj, std::string>;
template class Cacheable<Obj, std::string>;
template class ObjectCacheable<Obj, std::string>;
@@ -43,7 +43,7 @@ BOOST_AUTO_TEST_CASE( miss )
{
TestCache tc;
BOOST_REQUIRE_EQUAL(0, tc.size());
- tc.add("key", 3, time(NULL) + 5);
+ tc.add("key", 3, time(nullptr) + 5);
BOOST_REQUIRE_EQUAL(1, tc.size());
BOOST_REQUIRE_EQUAL(nullptr, tc.get("anything"));
BOOST_REQUIRE_EQUAL(nullptr, tc.getItem("anything"));
@@ -53,7 +53,7 @@ BOOST_AUTO_TEST_CASE( miss )
BOOST_AUTO_TEST_CASE( hit )
{
TestCache tc;
- auto vu = time(NULL) + 5;
+ auto vu = time(nullptr) + 5;
tc.add("key", 3, vu);
BOOST_REQUIRE_EQUAL(1, tc.size());
BOOST_REQUIRE_EQUAL(3, *tc.get("key"));
@@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE( hit )
BOOST_AUTO_TEST_CASE( multivalues )
{
TestCache tc;
- auto vu = time(NULL) + 5;
+ auto vu = time(nullptr) + 5;
tc.add("key1", 1, vu);
tc.add("key2", 2, vu);
tc.add("key3", 3, vu);
@@ -88,8 +88,8 @@ BOOST_AUTO_TEST_CASE( multivalues )
BOOST_AUTO_TEST_CASE( expired )
{
TestCache tc;
- tc.add("miss", 3, time(NULL) - 5);
- tc.add("hit", 3, time(NULL) + 5);
+ tc.add("miss", 3, time(nullptr) - 5);
+ tc.add("hit", 3, time(nullptr) + 5);
// We only prune once a second... so size() should stay at 1
BOOST_REQUIRE_EQUAL(2, tc.size());
BOOST_REQUIRE_EQUAL(nullptr, tc.get("miss"));
@@ -110,7 +110,7 @@ BOOST_AUTO_TEST_CASE( callcache )
{
TestCache tc;
int callCount = 0;
- auto vu = time(NULL) + 5;
+ auto vu = time(nullptr) + 5;
BOOST_REQUIRE_EQUAL(nullptr, tc.get("key"));
tc.addFactory("key", [&callCount]{ callCount++; return 3; }, vu);
BOOST_REQUIRE_EQUAL(0, callCount);
@@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE( pointercallcache )
{
TestCache tc;
int callCount = 0;
- auto vu = time(NULL) + 5;
+ auto vu = time(nullptr) + 5;
BOOST_REQUIRE_EQUAL(nullptr, tc.get("key"));
tc.addPointerFactory("key", [&callCount]{ callCount++; return TestCache::Value(new Obj(3)); }, vu);
BOOST_REQUIRE_EQUAL(0, callCount);
@@ -137,7 +137,7 @@ BOOST_AUTO_TEST_CASE( pointercallcache )
BOOST_AUTO_TEST_CASE( hitThenRenove )
{
TestCache tc;
- tc.add("key", 3, time(NULL) + 5);
+ tc.add("key", 3, time(nullptr) + 5);
auto h = tc.get("key");
BOOST_REQUIRE(h);
BOOST_REQUIRE_EQUAL(3, *h);
@@ -150,7 +150,7 @@ BOOST_AUTO_TEST_CASE( addPointer )
{
TestCache tc;
auto v = TestCache::Value(new Obj(3));
- tc.addPointer("key", v, time(NULL) + 1);
+ tc.addPointer("key", v, time(nullptr) + 1);
auto h = tc.get("key");
BOOST_REQUIRE(h);
BOOST_REQUIRE_EQUAL(3, *h);
diff --git a/libadhocutil/unittests/testCompileTimeFormatter.cpp b/libadhocutil/unittests/testCompileTimeFormatter.cpp
index 001349f..12b72b8 100644
--- a/libadhocutil/unittests/testCompileTimeFormatter.cpp
+++ b/libadhocutil/unittests/testCompileTimeFormatter.cpp
@@ -229,7 +229,7 @@ BOOST_AUTO_TEST_CASE ( customParam2 )
BOOST_CHECK_EQUAL(this->str(), "custom ---------( some text here )---------");
}
-typedef Formatter<formatStringCustom> TestFormat;
+using TestFormat = Formatter<formatStringCustom>;
BOOST_AUTO_TEST_CASE ( typedefFormat )
{
TestFormat::write(*this, "expr");
@@ -273,7 +273,7 @@ constexpr
#include <lorem-ipsum.h>
BOOST_AUTO_TEST_CASE( lorem_ipsum )
{
- typedef Formatter<lorem_ipsum_txt, sizeof(lorem_ipsum_txt)> LIF;
+ using LIF = Formatter<lorem_ipsum_txt, sizeof(lorem_ipsum_txt)>;
auto s = LIF::get();
BOOST_CHECK_EQUAL(s.length(), lorem_ipsum_txt_len);
AdHoc::FileUtils::MemMap li(rootDir / "lorem-ipsum.txt");
@@ -298,7 +298,7 @@ operator<<(FILE & strm, const char * const p)
BOOST_AUTO_TEST_CASE( filestar )
{
- char * buf = NULL;
+ char * buf = nullptr;
size_t len = 0;
FILE * strm = open_memstream(&buf, &len);
BOOST_REQUIRE(strm);
diff --git a/libadhocutil/unittests/testException.cpp b/libadhocutil/unittests/testException.cpp
index 5794468..63fc2a3 100644
--- a/libadhocutil/unittests/testException.cpp
+++ b/libadhocutil/unittests/testException.cpp
@@ -11,7 +11,7 @@ class Ex1 : public AdHoc::StdException {
Ex1(const char * f, int l) : file(f), line(l) { }
private:
- std::string message() const throw() override
+ std::string message() const noexcept override
{
return stringf("Something something at %s:%d", file, line);
}
@@ -27,7 +27,7 @@ class Ex2 : public AdHoc::Exception<OtherBaseException> {
Ex2(const char * f, int l) : file(f), line(l) { }
private:
- std::string message() const throw() override
+ std::string message() const noexcept override
{
return stringf("Something other something at %s:%d", file, line);
}
@@ -39,7 +39,7 @@ class Ex2 : public AdHoc::Exception<OtherBaseException> {
class Ex3 : public AdHoc::StdException {
private:
// LCOV_EXCL_START
- std::string message() const throw() override
+ std::string message() const noexcept override
{
// Never called
std::abort();
diff --git a/libadhocutil/unittests/testFactory.cpp b/libadhocutil/unittests/testFactory.cpp
index 0eb959c..b8b910d 100644
--- a/libadhocutil/unittests/testFactory.cpp
+++ b/libadhocutil/unittests/testFactory.cpp
@@ -26,7 +26,7 @@ class BaseThing {
class ImplOfThing : public BaseThing {
public:
ImplOfThing(int i, std::string * s) : BaseThing(i, s) {}
- void execute() const
+ void execute() const override
{
*name = typeid(this).name();
}
@@ -34,13 +34,13 @@ class ImplOfThing : public BaseThing {
class OtherImplOfThing : public BaseThing {
public:
OtherImplOfThing(int i, std::string * s) : BaseThing(i, s) {}
- void execute() const
+ void execute() const override
{
*name = typeid(this).name();
}
};
-typedef AdHoc::Factory<BaseThing, int, std::string *> BaseThingFactory;
+using BaseThingFactory = AdHoc::Factory<BaseThing, int, std::string *>;
NAMEDFACTORY("a", ImplOfThing, BaseThingFactory);
FACTORY(OtherImplOfThing, BaseThingFactory);
diff --git a/libadhocutil/unittests/testLazyPointer.cpp b/libadhocutil/unittests/testLazyPointer.cpp
index a747f17..a659548 100644
--- a/libadhocutil/unittests/testLazyPointer.cpp
+++ b/libadhocutil/unittests/testLazyPointer.cpp
@@ -14,8 +14,8 @@ class Test {
const int val;
};
-typedef LazyPointer<Test> TestLazyPointer;
-typedef LazyPointer<int, int *> RawLazyPointer;
+using TestLazyPointer = LazyPointer<Test>;
+using RawLazyPointer = LazyPointer<int, int *>;
static
TestLazyPointer::pointer_type
diff --git a/libadhocutil/unittests/testResourcePool.cpp b/libadhocutil/unittests/testResourcePool.cpp
index a7837b8..e37cc85 100644
--- a/libadhocutil/unittests/testResourcePool.cpp
+++ b/libadhocutil/unittests/testResourcePool.cpp
@@ -295,7 +295,6 @@ BOOST_AUTO_TEST_CASE( threading2 )
class TTRP : public TRP {
public:
- TTRP() : n(0) { }
void testResource(MockResource const *) const override
{
n += 1;
@@ -304,7 +303,7 @@ class TTRP : public TRP {
}
}
private:
- mutable int n;
+ mutable int n{0};
};
BOOST_AUTO_TEST_CASE( test )
diff --git a/libadhocutil/uriParse.cpp b/libadhocutil/uriParse.cpp
index 2419bb6..2d8a557 100644
--- a/libadhocutil/uriParse.cpp
+++ b/libadhocutil/uriParse.cpp
@@ -1,6 +1,7 @@
#include "uriParse.h"
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/lexical_cast.hpp>
+#include <utility>
#include "compileTimeFormatter.h"
namespace AdHoc {
@@ -171,17 +172,17 @@ namespace AdHoc {
}
}
- InvalidUri::InvalidUri(const std::string & e, const std::string & u) :
+ InvalidUri::InvalidUri(std::string e, std::string u) :
Exception<std::invalid_argument>(std::string()),
- err(e),
- uri(u)
+ err(std::move(e)),
+ uri(std::move(u))
{
}
AdHocFormatter(InvalidUriMsg, "InvalidUri (%?) parsing [%?]");
std::string
- InvalidUri::message() const throw()
+ InvalidUri::message() const noexcept
{
return InvalidUriMsg::get(err, uri);
}
diff --git a/libadhocutil/uriParse.h b/libadhocutil/uriParse.h
index 72c1a4c..309737f 100644
--- a/libadhocutil/uriParse.h
+++ b/libadhocutil/uriParse.h
@@ -42,9 +42,9 @@ namespace AdHoc {
class DLL_PUBLIC InvalidUri : public Exception<std::invalid_argument> {
public:
/// Constructor accepting what went wrong and the URI being parsed.
- InvalidUri(const std::string & err, const std::string & uri);
+ InvalidUri(std::string err, std::string uri);
- std::string message() const throw() override;
+ std::string message() const noexcept override;
/// The parse error.
const std::string err;