From 692b624398a3b9fbb560f47e13b588a92479a68d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 30 Sep 2010 08:23:42 +0000 Subject: Declare single-argument constructors explicit (except where implicit conversion is actually desired). See http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Explicit_Constructors git-svn-id: http://svn.drobilla.net/lad/trunk/raul@2619 a436a847-0d15-0410-975c-d299462d15a1 --- raul/Array.hpp | 2 +- raul/ArrayStack.hpp | 2 +- raul/Configuration.hpp | 2 +- raul/EventRingBuffer.hpp | 2 +- raul/List.hpp | 8 ++++---- raul/Maid.hpp | 2 +- raul/RingBuffer.hpp | 2 +- raul/SMFReader.hpp | 2 +- raul/SMFWriter.hpp | 2 +- raul/SRMWQueue.hpp | 2 +- raul/SRSWQueue.hpp | 2 +- raul/Thread.hpp | 2 +- 12 files changed, 15 insertions(+), 15 deletions(-) diff --git a/raul/Array.hpp b/raul/Array.hpp index 2cf22bf..0075c34 100644 --- a/raul/Array.hpp +++ b/raul/Array.hpp @@ -36,7 +36,7 @@ template class Array : public Deletable { public: - Array(size_t size = 0) : _size(size), _elems(NULL) { + explicit Array(size_t size = 0) : _size(size), _elems(NULL) { if (size > 0) _elems = new T[size]; } diff --git a/raul/ArrayStack.hpp b/raul/ArrayStack.hpp index e4aa33c..2204b69 100644 --- a/raul/ArrayStack.hpp +++ b/raul/ArrayStack.hpp @@ -33,7 +33,7 @@ template class ArrayStack : public Array { public: - ArrayStack(size_t size = 0) : Array(size), _top(0) {} + explicit ArrayStack(size_t size = 0) : Array(size), _top(0) {} ArrayStack(size_t size, T initial_value) : Array(size, initial_value), _top(0) {} diff --git a/raul/Configuration.hpp b/raul/Configuration.hpp index 7780b85..e26de9d 100644 --- a/raul/Configuration.hpp +++ b/raul/Configuration.hpp @@ -49,7 +49,7 @@ public: void print_usage(const std::string& program, std::ostream& os); struct CommandLineError : public std::exception { - CommandLineError(const std::string& m) : msg(m) {} + explicit CommandLineError(const std::string& m) : msg(m) {} ~CommandLineError() throw() {} const char* what() const throw() { return msg.c_str(); } std::string msg; diff --git a/raul/EventRingBuffer.hpp b/raul/EventRingBuffer.hpp index 5e37395..418d2af 100644 --- a/raul/EventRingBuffer.hpp +++ b/raul/EventRingBuffer.hpp @@ -36,7 +36,7 @@ public: /** @param capacity Ringbuffer capacity in bytes. */ - EventRingBuffer(size_t capacity) + explicit EventRingBuffer(size_t capacity) : RingBuffer(capacity) {} diff --git a/raul/List.hpp b/raul/List.hpp index 5b55aec..199756f 100644 --- a/raul/List.hpp +++ b/raul/List.hpp @@ -47,11 +47,11 @@ public: */ class Node : public Raul::Deletable { public: - Node(T elem) : _elem(elem) {} + explicit Node(T elem) : _elem(elem) {} virtual ~Node() {} template - Node(const typename List::Node& copy) + explicit Node(const typename List::Node& copy) : _elem(copy._elem), _prev(copy._prev), _next(copy._next) {} @@ -100,7 +100,7 @@ public: /** Realtime safe const iterator for a List. */ class const_iterator { public: - const_iterator(const List* const list); + explicit const_iterator(const List* const list); const_iterator(const iterator& i) : _list(i._list), _listnode(i._listnode) {} @@ -126,7 +126,7 @@ public: /** Realtime safe iterator for a List. */ class iterator { public: - iterator(List* const list); + explicit iterator(List* const list); inline T& operator*(); inline T* operator->(); diff --git a/raul/Maid.hpp b/raul/Maid.hpp index 57b2f73..b1ebcbe 100644 --- a/raul/Maid.hpp +++ b/raul/Maid.hpp @@ -46,7 +46,7 @@ namespace Raul { class Maid : boost::noncopyable { public: - Maid(size_t size); + explicit Maid(size_t size); ~Maid(); /** Push a raw pointer to be deleted when cleanup() is called next. diff --git a/raul/RingBuffer.hpp b/raul/RingBuffer.hpp index 2972258..31ab222 100644 --- a/raul/RingBuffer.hpp +++ b/raul/RingBuffer.hpp @@ -37,7 +37,7 @@ class RingBuffer { public: /** @param size Size in bytes. */ - RingBuffer(size_t size) + explicit RingBuffer(size_t size) : _size(size) , _buf(static_cast(malloc(size))) { diff --git a/raul/SMFReader.hpp b/raul/SMFReader.hpp index a96c6aa..1e1b5e8 100644 --- a/raul/SMFReader.hpp +++ b/raul/SMFReader.hpp @@ -42,7 +42,7 @@ public: const char* what() const throw() { return "Unsupported time stamp type (SMPTE)"; } }; - SMFReader(const std::string filename=""); + explicit SMFReader(const std::string filename=""); ~SMFReader(); bool open(const std::string& filename) throw (std::logic_error, UnsupportedTime); diff --git a/raul/SMFWriter.hpp b/raul/SMFWriter.hpp index 5c0ffef..4643624 100644 --- a/raul/SMFWriter.hpp +++ b/raul/SMFWriter.hpp @@ -29,7 +29,7 @@ namespace Raul { */ class SMFWriter : public Raul::MIDISink { public: - SMFWriter(TimeUnit unit); + explicit SMFWriter(TimeUnit unit); ~SMFWriter(); bool start(const std::string& filename, diff --git a/raul/SRMWQueue.hpp b/raul/SRMWQueue.hpp index 18b2461..7257ec3 100644 --- a/raul/SRMWQueue.hpp +++ b/raul/SRMWQueue.hpp @@ -52,7 +52,7 @@ template class SRMWQueue : boost::noncopyable { public: - SRMWQueue(size_t size); + explicit SRMWQueue(size_t size); ~SRMWQueue(); diff --git a/raul/SRSWQueue.hpp b/raul/SRSWQueue.hpp index b85cc15..e089f07 100644 --- a/raul/SRSWQueue.hpp +++ b/raul/SRSWQueue.hpp @@ -42,7 +42,7 @@ class SRSWQueue : boost::noncopyable { public: /** @param size Size in number of elements */ - SRSWQueue(size_t size); + explicit SRSWQueue(size_t size); ~SRSWQueue(); // Any thread: diff --git a/raul/Thread.hpp b/raul/Thread.hpp index 3c624a7..757b791 100644 --- a/raul/Thread.hpp +++ b/raul/Thread.hpp @@ -64,7 +64,7 @@ public: void set_context(unsigned context) { _contexts.insert(context); } protected: - Thread(const std::string& name=""); + explicit Thread(const std::string& name=""); Thread(pthread_t thread, const std::string& name=""); /** Thread function to execute. -- cgit v1.2.1