Cycles: Use explicit qualifier for single-argument constructors
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 11 May 2016 14:50:10 +0000 (16:50 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 11 May 2016 14:51:14 +0000 (16:51 +0200)
Almost in all cases we want such constructors to be explicit, there are
exceptions but only in few places.

20 files changed:
intern/cycles/bvh/bvh_node.h
intern/cycles/bvh/bvh_sort.cpp
intern/cycles/device/device_multi.cpp
intern/cycles/device/device_network.h
intern/cycles/device/device_task.h
intern/cycles/render/attribute.h
intern/cycles/render/buffers.h
intern/cycles/render/graph.h
intern/cycles/render/image.h
intern/cycles/render/nodes.h
intern/cycles/render/session.h
intern/cycles/render/svm.h
intern/cycles/subd/subd_dice.h
intern/cycles/subd/subd_mesh.cpp
intern/cycles/subd/subd_split.h
intern/cycles/util/util_debug.h
intern/cycles/util/util_path.cpp
intern/cycles/util/util_task.h
intern/cycles/util/util_time.h
intern/cycles/util/util_vector.h

index 44f5518229befa65a52330ac8c6deaaeb1b67627..d476fb917edaa28c6f989a5f7c91a3b9633698b9 100644 (file)
@@ -75,7 +75,7 @@ public:
                        m_visibility = 0; /* happens on build cancel */
        }
 
-       InnerNode(const BoundBox& bounds)
+       explicit InnerNode(const BoundBox& bounds)
        {
                m_bounds = bounds;
                m_visibility = 0;
index c12751979cd82e4a12209a19afe81e16eff446f3..f6bbdb231df2069ee9264f471e6717e985b37a68 100644 (file)
@@ -40,7 +40,7 @@ struct BVHReferenceCompare {
 public:
        int dim;
 
-       BVHReferenceCompare(int dim_)
+       explicit BVHReferenceCompare(int dim_)
        {
                dim = dim_;
        }
@@ -184,7 +184,7 @@ void bvh_reference_sort(int start, int end, BVHReference *data, int dim)
        }
        else {
                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();
        }
 }
index 069305e8a292cae9a0945744eb3894d8bcdb7189..6141f9af50f80a53a694b5d1af1e1f0b24e91937 100644 (file)
@@ -35,7 +35,7 @@ class MultiDevice : public Device
 {
 public:
        struct SubDevice {
-               SubDevice(Device *device_)
+               explicit SubDevice(Device *device_)
                : device(device_) {}
 
                Device *device;
index 60ecc1d0a86a771f0f14e984791dd29a34ef1cb4..d28cfe3121f58592df92708ccce5d29ba14683ac 100644 (file)
@@ -322,7 +322,7 @@ protected:
 
 class ServerDiscovery {
 public:
-       ServerDiscovery(bool discover = false)
+       explicit ServerDiscovery(bool discover = false)
        : listen_socket(io_service), collect_servers(false)
        {
                /* setup listen socket */
index d7912f386f5c165d0badfe9d4fcbb8b7a1d67307..8423e83bdfd14687ad2c04094278dddacb43e09c 100644 (file)
@@ -51,7 +51,7 @@ public:
        int shader_filter;
        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);
        void split(list<DeviceTask>& tasks, int num, int max_size = 0);
index bbc6cf7f65f7a4c120a5a28b6eaf5067a38d332a..01102d22aaa2d9fb78fd07108fe61e3ef671b902 100644 (file)
@@ -134,8 +134,8 @@ public:
        AttributeElement triangle_element, curve_element;
        int triangle_offset, curve_offset;
 
-       AttributeRequest(ustring name_);
-       AttributeRequest(AttributeStandard std);
+       explicit AttributeRequest(ustring name_);
+       explicit AttributeRequest(AttributeStandard std);
 };
 
 /* AttributeRequestSet
index 4fa1c51d821515c4f2940523d816210bdde2471a..57ffd9630f50a3a8194922b9dc6aed46d2b598bd 100644 (file)
@@ -73,7 +73,7 @@ public:
        /* random number generator state */
        device_vector<uint> rng_state;
 
-       RenderBuffers(Device *device);
+       explicit RenderBuffers(Device *device);
        ~RenderBuffers();
 
        void reset(Device *device, BufferParams& params);
index 6619fcaebebf7e2ebfc25d3314efdaa5f436b8ab..b1ebdbfd51da2d3ddd32ef7108b6f35dfbad6ee8 100644 (file)
@@ -177,7 +177,7 @@ public:
 
 class ShaderNode {
 public:
-       ShaderNode(const char *name);
+       explicit ShaderNode(const char *name);
        virtual ~ShaderNode();
 
        ShaderInput *input(const char *name);
index 1bb9987f60253325d08f32031397fcc957d55bcf..02dc189b5ec6d922e65b96c2b8ea4bbe63bb0e07 100644 (file)
@@ -32,7 +32,7 @@ class Progress;
 
 class ImageManager {
 public:
-       ImageManager(const DeviceInfo& info);
+       explicit ImageManager(const DeviceInfo& info);
        ~ImageManager();
 
        enum ImageDataType {
index 7ae37a633ca6708cd2fd24d3fa00a7b8d66b3517..ccfea033c129db253a64af397c5051cbb37c0833 100644 (file)
@@ -75,7 +75,7 @@ public:
 
 class TextureNode : public ShaderNode {
 public:
-       TextureNode(const char *name_) : ShaderNode(name_) {}
+       explicit TextureNode(const char *name_) : ShaderNode(name_) {}
        TextureMapping tex_mapping;
 
        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. */
 class ImageSlotTextureNode : public TextureNode {
 public:
-       ImageSlotTextureNode(const char *name_) : TextureNode(name_) {
+       explicit ImageSlotTextureNode(const char *name_) : TextureNode(name_) {
                special_type = SHADER_SPECIAL_TYPE_IMAGE_SLOT;
        }
        int slot;
@@ -379,7 +379,7 @@ public:
 
 class BsdfNode : public ShaderNode {
 public:
-       BsdfNode(bool scattering = false);
+       explicit BsdfNode(bool scattering = false);
        SHADER_NODE_BASE_CLASS(BsdfNode);
 
        bool has_spatial_varying() { return true; }
index 02d97ce9a87184b3626f5fb0ebfa40efe3955dfe..8bff0f9ed15fcb51dd2bd83ad1cb5373fd487f78 100644 (file)
@@ -129,7 +129,7 @@ public:
        function<void(RenderTile&)> write_render_tile_cb;
        function<void(RenderTile&)> update_render_tile_cb;
 
-       Session(const SessionParams& params);
+       explicit Session(const SessionParams& params);
        ~Session();
 
        void start();
index f4777dee89dfddcadc8572e45c8e036435900e3e..5ff98ac6e913d608ec77cbde38ff26abd9e52725 100644 (file)
@@ -150,7 +150,7 @@ protected:
 
        /* Global state of the compiler accessible from the compilation routines. */
        struct CompilerState {
-               CompilerState(ShaderGraph *graph);
+               explicit CompilerState(ShaderGraph *graph);
 
                /* ** Global state, used by various compilation steps. ** */
 
index 8450a43129e3a20a61a238288d01707cf813801d..49f786e949ee7863e09ec7d07b05559e7c962277 100644 (file)
@@ -70,7 +70,7 @@ public:
        size_t vert_offset;
        size_t tri_offset;
 
-       EdgeDice(const SubdParams& params);
+       explicit EdgeDice(const SubdParams& params);
 
        void reserve(int num_verts, int num_tris);
 
@@ -111,7 +111,7 @@ public:
                int tv1;
        };
 
-       QuadDice(const SubdParams& params);
+       explicit QuadDice(const SubdParams& params);
 
        void reserve(EdgeFactors& ef, int Mu, int Mv);
        float3 eval_projected(SubPatch& sub, float u, float v);
@@ -165,7 +165,7 @@ public:
                int tw;
        };
 
-       TriangleDice(const SubdParams& params);
+       explicit TriangleDice(const SubdParams& params);
 
        void reserve(EdgeFactors& ef, int M);
 
index d7cb7b921eeeff71db8b574b9f78d27e95842a39..56d7d2b23031a58dcadcd1a13b7c70a4073d18f5 100644 (file)
@@ -291,7 +291,7 @@ public:
        int id;
        float3 co;
        
-       SubdVert(int id_)
+       explicit SubdVert(int id_)
        {
                id = id_;
                co = make_float3(0.0f, 0.0f, 0.0f);
@@ -307,7 +307,7 @@ public:
        int numverts;
        int verts[4];
 
-       SubdFace(int id_)
+       explicit SubdFace(int id_)
        {
                id = id_;
                numverts = 0;
index f04c51dedfee97f4757f0caf796a49fd5e2ca50d..bbe921f739c03c24dd2315e125ad94d4497b3f23 100644 (file)
@@ -43,7 +43,7 @@ public:
 
        SubdParams params;
 
-       DiagSplit(const SubdParams& params);
+       explicit DiagSplit(const SubdParams& params);
 
        float3 to_world(Patch *patch, float2 uv);
        int T(Patch *patch, float2 Pstart, float2 Pend);
index 641abcc0668ed481ee7587519340116852789a69..1787ff648ee343efec606fabcee280f0afb6cd47 100644 (file)
@@ -130,11 +130,11 @@ private:
 
 #if (__cplusplus > 199711L)
 public:
-       DebugFlags(DebugFlags const& /*other*/)     = delete;
+       explicit DebugFlags(DebugFlags const& /*other*/)     = delete;
        void operator=(DebugFlags const& /*other*/) = delete;
 #else
 private:
-       DebugFlags(DebugFlags const& /*other*/);
+       explicit DebugFlags(DebugFlags const& /*other*/);
        void operator=(DebugFlags const& /*other*/);
 #endif
 };
index 83754728dbed7acf4fd15db8e891c14aab2c8cff..0c848beaafd1c049014c024e8cc69a33da3e9504 100644 (file)
@@ -92,7 +92,7 @@ public:
        {
        }
 
-       directory_iterator(const string& path)
+       explicit directory_iterator(const string& path)
        : path_(path),
          path_info_(path, find_data_)
        {
@@ -176,7 +176,7 @@ class directory_iterator {
 public:
        class path_info {
        public:
-               path_info(const string& path)
+               explicit path_info(const string& path)
                : path_(path),
                  entry_(NULL)
                {
@@ -203,7 +203,7 @@ public:
        {
        }
 
-       directory_iterator(const string& path)
+       explicit directory_iterator(const string& path)
        : path_(path),
          path_info_(path_),
          cur_entry_(0)
index d697ebf35a448468420683aeb6b8f798104a6489..0b82f14f66f159c4be936957f73bba637474c7ff 100644 (file)
@@ -52,7 +52,7 @@ class Task
 {
 public:
        Task() {};
-       Task(const TaskRunFunction& run_) : run(run_) {}
+       explicit Task(const TaskRunFunction& run_) : run(run_) {}
 
        virtual ~Task() {}
 
index 9cd52d5f11af4499325b779dcd33faca483853d4..a5b074bffa0958378751f7fc1fe86a2252b49fbc 100644 (file)
@@ -29,7 +29,7 @@ void time_sleep(double t);
 
 class scoped_timer {
 public:
-       scoped_timer(double *value) : value_(value)
+       explicit scoped_timer(double *value) : value_(value)
        {
                time_start_ = time_dt();
        }
index ad579da2d2e928b58f58ce23124b51f9cc4f4482..b5ee7f98a1544b14f8c866bd6b304c4a63fb341f 100644 (file)
@@ -98,7 +98,7 @@ public:
          capacity_(0)
        {}
 
-       array(size_t newsize)
+       explicit array(size_t newsize)
        {
                if(newsize == 0) {
                        data_ = NULL;