Cycles: Use explicit qualifier for single-argument constructors

Almost in all cases we want such constructors to be explicit, there are
exceptions but only in few places.
This commit is contained in:
Sergey Sharybin
2016-05-11 16:50:10 +02:00
parent d57f416e47
commit 92774ff792
20 changed files with 30 additions and 30 deletions

View File

@@ -75,7 +75,7 @@ public:
m_visibility = 0; /* happens on build cancel */ m_visibility = 0; /* happens on build cancel */
} }
InnerNode(const BoundBox& bounds) explicit InnerNode(const BoundBox& bounds)
{ {
m_bounds = bounds; m_bounds = bounds;
m_visibility = 0; m_visibility = 0;

View File

@@ -40,7 +40,7 @@ struct BVHReferenceCompare {
public: public:
int dim; int dim;
BVHReferenceCompare(int dim_) explicit BVHReferenceCompare(int dim_)
{ {
dim = dim_; dim = dim_;
} }
@@ -184,7 +184,7 @@ void bvh_reference_sort(int start, int end, BVHReference *data, int dim)
} }
else { else {
TaskPool task_pool; TaskPool task_pool;
bvh_reference_sort_threaded(&task_pool, data, start, end - 1, dim); bvh_reference_sort_threaded(&task_pool, data, start, end - 1, compare);
task_pool.wait_work(); task_pool.wait_work();
} }
} }

View File

@@ -35,7 +35,7 @@ class MultiDevice : public Device
{ {
public: public:
struct SubDevice { struct SubDevice {
SubDevice(Device *device_) explicit SubDevice(Device *device_)
: device(device_) {} : device(device_) {}
Device *device; Device *device;

View File

@@ -322,7 +322,7 @@ protected:
class ServerDiscovery { class ServerDiscovery {
public: public:
ServerDiscovery(bool discover = false) explicit ServerDiscovery(bool discover = false)
: listen_socket(io_service), collect_servers(false) : listen_socket(io_service), collect_servers(false)
{ {
/* setup listen socket */ /* setup listen socket */

View File

@@ -51,7 +51,7 @@ public:
int shader_filter; int shader_filter;
int shader_x, shader_w; int shader_x, shader_w;
DeviceTask(Type type = PATH_TRACE); explicit DeviceTask(Type type = PATH_TRACE);
int get_subtask_count(int num, int max_size = 0); int get_subtask_count(int num, int max_size = 0);
void split(list<DeviceTask>& tasks, int num, int max_size = 0); void split(list<DeviceTask>& tasks, int num, int max_size = 0);

View File

@@ -134,8 +134,8 @@ public:
AttributeElement triangle_element, curve_element; AttributeElement triangle_element, curve_element;
int triangle_offset, curve_offset; int triangle_offset, curve_offset;
AttributeRequest(ustring name_); explicit AttributeRequest(ustring name_);
AttributeRequest(AttributeStandard std); explicit AttributeRequest(AttributeStandard std);
}; };
/* AttributeRequestSet /* AttributeRequestSet

View File

@@ -73,7 +73,7 @@ public:
/* random number generator state */ /* random number generator state */
device_vector<uint> rng_state; device_vector<uint> rng_state;
RenderBuffers(Device *device); explicit RenderBuffers(Device *device);
~RenderBuffers(); ~RenderBuffers();
void reset(Device *device, BufferParams& params); void reset(Device *device, BufferParams& params);

View File

@@ -177,7 +177,7 @@ public:
class ShaderNode { class ShaderNode {
public: public:
ShaderNode(const char *name); explicit ShaderNode(const char *name);
virtual ~ShaderNode(); virtual ~ShaderNode();
ShaderInput *input(const char *name); ShaderInput *input(const char *name);

View File

@@ -32,7 +32,7 @@ class Progress;
class ImageManager { class ImageManager {
public: public:
ImageManager(const DeviceInfo& info); explicit ImageManager(const DeviceInfo& info);
~ImageManager(); ~ImageManager();
enum ImageDataType { enum ImageDataType {

View File

@@ -75,7 +75,7 @@ public:
class TextureNode : public ShaderNode { class TextureNode : public ShaderNode {
public: public:
TextureNode(const char *name_) : ShaderNode(name_) {} explicit TextureNode(const char *name_) : ShaderNode(name_) {}
TextureMapping tex_mapping; TextureMapping tex_mapping;
virtual bool equals(const ShaderNode *other) { virtual bool equals(const ShaderNode *other) {
@@ -87,7 +87,7 @@ public:
/* Any node which uses image manager's slot should be a subclass of this one. */ /* Any node which uses image manager's slot should be a subclass of this one. */
class ImageSlotTextureNode : public TextureNode { class ImageSlotTextureNode : public TextureNode {
public: public:
ImageSlotTextureNode(const char *name_) : TextureNode(name_) { explicit ImageSlotTextureNode(const char *name_) : TextureNode(name_) {
special_type = SHADER_SPECIAL_TYPE_IMAGE_SLOT; special_type = SHADER_SPECIAL_TYPE_IMAGE_SLOT;
} }
int slot; int slot;
@@ -379,7 +379,7 @@ public:
class BsdfNode : public ShaderNode { class BsdfNode : public ShaderNode {
public: public:
BsdfNode(bool scattering = false); explicit BsdfNode(bool scattering = false);
SHADER_NODE_BASE_CLASS(BsdfNode); SHADER_NODE_BASE_CLASS(BsdfNode);
bool has_spatial_varying() { return true; } bool has_spatial_varying() { return true; }

View File

@@ -129,7 +129,7 @@ public:
function<void(RenderTile&)> write_render_tile_cb; function<void(RenderTile&)> write_render_tile_cb;
function<void(RenderTile&)> update_render_tile_cb; function<void(RenderTile&)> update_render_tile_cb;
Session(const SessionParams& params); explicit Session(const SessionParams& params);
~Session(); ~Session();
void start(); void start();

View File

@@ -150,7 +150,7 @@ protected:
/* Global state of the compiler accessible from the compilation routines. */ /* Global state of the compiler accessible from the compilation routines. */
struct CompilerState { struct CompilerState {
CompilerState(ShaderGraph *graph); explicit CompilerState(ShaderGraph *graph);
/* ** Global state, used by various compilation steps. ** */ /* ** Global state, used by various compilation steps. ** */

View File

@@ -70,7 +70,7 @@ public:
size_t vert_offset; size_t vert_offset;
size_t tri_offset; size_t tri_offset;
EdgeDice(const SubdParams& params); explicit EdgeDice(const SubdParams& params);
void reserve(int num_verts, int num_tris); void reserve(int num_verts, int num_tris);
@@ -111,7 +111,7 @@ public:
int tv1; int tv1;
}; };
QuadDice(const SubdParams& params); explicit QuadDice(const SubdParams& params);
void reserve(EdgeFactors& ef, int Mu, int Mv); void reserve(EdgeFactors& ef, int Mu, int Mv);
float3 eval_projected(SubPatch& sub, float u, float v); float3 eval_projected(SubPatch& sub, float u, float v);
@@ -165,7 +165,7 @@ public:
int tw; int tw;
}; };
TriangleDice(const SubdParams& params); explicit TriangleDice(const SubdParams& params);
void reserve(EdgeFactors& ef, int M); void reserve(EdgeFactors& ef, int M);

View File

@@ -291,7 +291,7 @@ public:
int id; int id;
float3 co; float3 co;
SubdVert(int id_) explicit SubdVert(int id_)
{ {
id = id_; id = id_;
co = make_float3(0.0f, 0.0f, 0.0f); co = make_float3(0.0f, 0.0f, 0.0f);
@@ -307,7 +307,7 @@ public:
int numverts; int numverts;
int verts[4]; int verts[4];
SubdFace(int id_) explicit SubdFace(int id_)
{ {
id = id_; id = id_;
numverts = 0; numverts = 0;

View File

@@ -43,7 +43,7 @@ public:
SubdParams params; SubdParams params;
DiagSplit(const SubdParams& params); explicit DiagSplit(const SubdParams& params);
float3 to_world(Patch *patch, float2 uv); float3 to_world(Patch *patch, float2 uv);
int T(Patch *patch, float2 Pstart, float2 Pend); int T(Patch *patch, float2 Pstart, float2 Pend);

View File

@@ -130,11 +130,11 @@ private:
#if (__cplusplus > 199711L) #if (__cplusplus > 199711L)
public: public:
DebugFlags(DebugFlags const& /*other*/) = delete; explicit DebugFlags(DebugFlags const& /*other*/) = delete;
void operator=(DebugFlags const& /*other*/) = delete; void operator=(DebugFlags const& /*other*/) = delete;
#else #else
private: private:
DebugFlags(DebugFlags const& /*other*/); explicit DebugFlags(DebugFlags const& /*other*/);
void operator=(DebugFlags const& /*other*/); void operator=(DebugFlags const& /*other*/);
#endif #endif
}; };

View File

@@ -92,7 +92,7 @@ public:
{ {
} }
directory_iterator(const string& path) explicit directory_iterator(const string& path)
: path_(path), : path_(path),
path_info_(path, find_data_) path_info_(path, find_data_)
{ {
@@ -176,7 +176,7 @@ class directory_iterator {
public: public:
class path_info { class path_info {
public: public:
path_info(const string& path) explicit path_info(const string& path)
: path_(path), : path_(path),
entry_(NULL) entry_(NULL)
{ {
@@ -203,7 +203,7 @@ public:
{ {
} }
directory_iterator(const string& path) explicit directory_iterator(const string& path)
: path_(path), : path_(path),
path_info_(path_), path_info_(path_),
cur_entry_(0) cur_entry_(0)

View File

@@ -52,7 +52,7 @@ class Task
{ {
public: public:
Task() {}; Task() {};
Task(const TaskRunFunction& run_) : run(run_) {} explicit Task(const TaskRunFunction& run_) : run(run_) {}
virtual ~Task() {} virtual ~Task() {}

View File

@@ -29,7 +29,7 @@ void time_sleep(double t);
class scoped_timer { class scoped_timer {
public: public:
scoped_timer(double *value) : value_(value) explicit scoped_timer(double *value) : value_(value)
{ {
time_start_ = time_dt(); time_start_ = time_dt();
} }

View File

@@ -98,7 +98,7 @@ public:
capacity_(0) capacity_(0)
{} {}
array(size_t newsize) explicit array(size_t newsize)
{ {
if(newsize == 0) { if(newsize == 0) {
data_ = NULL; data_ = NULL;