Skip to content

Commit

Permalink
misc: mark constructors as explicit
Browse files Browse the repository at this point in the history
Set 4 constructors as explicit to avoid implicit usage.

Fix for cppcheck warning:
 Class has a constructor with 1 argument that is
 not explicit. Such constructors should in general be explicit for
 type safety reasons. Using the explicit keyword in the constructor
 means some mistakes when using the class can be avoided.

 For more information check:
  https://www.codeproject.com/Articles/28663/Explicit-Constructor-in-C

Signed-off-by: Danny Al-Gaaf <[email protected]>
  • Loading branch information
dalgaaf authored and ivancich committed May 10, 2018
1 parent 17662d8 commit a994998
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sim/src/sim_recs.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace crimson {
struct TestResponse {
uint32_t epoch;

TestResponse(uint32_t _epoch) :
explicit TestResponse(uint32_t _epoch) :
epoch(_epoch)
{
// empty
Expand Down
2 changes: 1 addition & 1 deletion support/test/test_ind_intru_heap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Test1 {

crimson::IndIntruHeapData heap_data;

Test1(int _data) : data(_data) {}
explicit Test1(int _data) : data(_data) {}

friend std::ostream& operator<<(std::ostream& out, const Test1& d) {
out << d.data << " (" << d.heap_data << ")";
Expand Down
2 changes: 1 addition & 1 deletion support/test/test_indirect_intrusive_heap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct Elem {
crimson::IndIntruHeapData heap_data;
crimson::IndIntruHeapData heap_data_alt;

Elem(int _data) : data(_data) { }
explicit Elem(int _data) : data(_data) { }

bool operator==(const Elem& other) {
return data == other.data;
Expand Down
2 changes: 1 addition & 1 deletion support/test/test_intrusive_heap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Test1 {
crimson::IntruHeapData heap_data;

public:
Test1(int _data) : data(_data) {}
explicit Test1(int _data) : data(_data) {}

friend std::ostream& operator<<(std::ostream& out, const Test1& d) {
out << d.data << " (" << d.heap_data << ")";
Expand Down

0 comments on commit a994998

Please sign in to comment.