Mark all single-argument constructors in user_objects.h as explicit.

This avoids accidental implicit conversions.

Also included some constructors with multiple arguments, where default values mean that the single-argument constructor is valid.

PiperOrigin-RevId: 772117936
Change-Id: I57e54a373593080e9d68961b00488c7a70f1aff8
This commit is contained in:
Nimrod Gileadi
2025-06-16 11:59:42 -07:00
committed by Copybara-Service
parent 1f0e4891c2
commit e2e2932fe6
+25 -25
View File
@@ -388,8 +388,8 @@ class mjCBody : public mjCBody_, private mjsBody {
friend class mjXURDF; friend class mjXURDF;
public: public:
mjCBody(mjCModel*); // constructor explicit mjCBody(mjCModel*);
~mjCBody(); // destructor ~mjCBody();
// API for adding objects to body // API for adding objects to body
mjCBody* AddBody(mjCDef* = 0); mjCBody* AddBody(mjCDef* = 0);
@@ -571,7 +571,7 @@ class mjCJoint : public mjCJoint_, private mjsJoint {
friend class mjXURDF; friend class mjXURDF;
public: public:
mjCJoint(mjCModel* = nullptr, mjCDef* = nullptr); explicit mjCJoint(mjCModel* = nullptr, mjCDef* = nullptr);
mjCJoint(const mjCJoint& other); mjCJoint(const mjCJoint& other);
mjCJoint& operator=(const mjCJoint& other); mjCJoint& operator=(const mjCJoint& other);
@@ -651,7 +651,7 @@ class mjCGeom : public mjCGeom_, private mjsGeom {
friend class mjXURDF; friend class mjXURDF;
public: public:
mjCGeom(mjCModel* = nullptr, mjCDef* = nullptr); explicit mjCGeom(mjCModel* = nullptr, mjCDef* = nullptr);
mjCGeom(const mjCGeom& other); mjCGeom(const mjCGeom& other);
mjCGeom& operator=(const mjCGeom& other); mjCGeom& operator=(const mjCGeom& other);
@@ -716,7 +716,7 @@ class mjCSite : public mjCSite_, private mjsSite {
friend class mjXURDF; friend class mjXURDF;
public: public:
mjCSite(mjCModel* = nullptr, mjCDef* = nullptr); explicit mjCSite(mjCModel* = nullptr, mjCDef* = nullptr);
mjCSite(const mjCSite& other); mjCSite(const mjCSite& other);
mjCSite& operator=(const mjCSite& other); mjCSite& operator=(const mjCSite& other);
@@ -766,7 +766,7 @@ class mjCCamera : public mjCCamera_, private mjsCamera {
friend class mjXWriter; friend class mjXWriter;
public: public:
mjCCamera(mjCModel* = nullptr, mjCDef* = nullptr); explicit mjCCamera(mjCModel* = nullptr, mjCDef* = nullptr);
mjCCamera(const mjCCamera& other); mjCCamera(const mjCCamera& other);
mjCCamera& operator=(const mjCCamera& other); mjCCamera& operator=(const mjCCamera& other);
@@ -812,7 +812,7 @@ class mjCLight : public mjCLight_, private mjsLight {
friend class mjXWriter; friend class mjXWriter;
public: public:
mjCLight(mjCModel* = nullptr, mjCDef* = nullptr); explicit mjCLight(mjCModel* = nullptr, mjCDef* = nullptr);
mjCLight(const mjCLight& other); mjCLight(const mjCLight& other);
mjCLight& operator=(const mjCLight& other); mjCLight& operator=(const mjCLight& other);
@@ -897,7 +897,7 @@ class mjCFlex: public mjCFlex_, private mjsFlex {
friend class mjXWriter; friend class mjXWriter;
public: public:
mjCFlex(mjCModel* = nullptr); explicit mjCFlex(mjCModel* = nullptr);
mjCFlex(const mjCFlex& other); mjCFlex(const mjCFlex& other);
mjCFlex& operator=(const mjCFlex& other); mjCFlex& operator=(const mjCFlex& other);
@@ -997,7 +997,7 @@ class mjCMesh: public mjCMesh_, private mjsMesh {
friend class mjCModel; friend class mjCModel;
public: public:
mjCMesh(mjCModel* = nullptr, mjCDef* = nullptr); explicit mjCMesh(mjCModel* = nullptr, mjCDef* = nullptr);
mjCMesh(const mjCMesh& other); mjCMesh(const mjCMesh& other);
mjCMesh& operator=(const mjCMesh& other); mjCMesh& operator=(const mjCMesh& other);
~mjCMesh(); ~mjCMesh();
@@ -1200,7 +1200,7 @@ class mjCSkin: public mjCSkin_, private mjsSkin {
friend class mjXWriter; friend class mjXWriter;
public: public:
mjCSkin(mjCModel* = nullptr); explicit mjCSkin(mjCModel* = nullptr);
mjCSkin(const mjCSkin& other); mjCSkin(const mjCSkin& other);
mjCSkin& operator=(const mjCSkin& other); mjCSkin& operator=(const mjCSkin& other);
~mjCSkin(); ~mjCSkin();
@@ -1258,7 +1258,7 @@ class mjCHField : public mjCHField_, private mjsHField {
friend class mjXWriter; friend class mjXWriter;
public: public:
mjCHField(mjCModel* model); explicit mjCHField(mjCModel* model);
mjCHField(const mjCHField& other); mjCHField(const mjCHField& other);
mjCHField& operator=(const mjCHField& other); mjCHField& operator=(const mjCHField& other);
~mjCHField(); ~mjCHField();
@@ -1310,7 +1310,7 @@ class mjCTexture : public mjCTexture_, private mjsTexture {
friend class mjXWriter; friend class mjXWriter;
public: public:
mjCTexture(mjCModel*); explicit mjCTexture(mjCModel*);
mjCTexture(const mjCTexture& other); mjCTexture(const mjCTexture& other);
mjCTexture& operator=(const mjCTexture& other); mjCTexture& operator=(const mjCTexture& other);
~mjCTexture(); ~mjCTexture();
@@ -1371,7 +1371,7 @@ class mjCMaterial : public mjCMaterial_, private mjsMaterial {
friend class mjXWriter; friend class mjXWriter;
public: public:
mjCMaterial(mjCModel* = nullptr, mjCDef* = nullptr); explicit mjCMaterial(mjCModel* = nullptr, mjCDef* = nullptr);
mjCMaterial(const mjCMaterial& other); mjCMaterial(const mjCMaterial& other);
mjCMaterial& operator=(const mjCMaterial& other); mjCMaterial& operator=(const mjCMaterial& other);
@@ -1411,7 +1411,7 @@ class mjCPair : public mjCPair_, private mjsPair {
friend class mjXWriter; friend class mjXWriter;
public: public:
mjCPair(mjCModel* = nullptr, mjCDef* = nullptr); explicit mjCPair(mjCModel* = nullptr, mjCDef* = nullptr);
mjCPair(const mjCPair& other); mjCPair(const mjCPair& other);
mjCPair& operator=(const mjCPair& other); mjCPair& operator=(const mjCPair& other);
@@ -1460,7 +1460,7 @@ class mjCBodyPair : public mjCBodyPair_, private mjsExclude {
friend class mjCModel; friend class mjCModel;
public: public:
mjCBodyPair(mjCModel*); explicit mjCBodyPair(mjCModel*);
mjCBodyPair(const mjCBodyPair& other); mjCBodyPair(const mjCBodyPair& other);
mjCBodyPair& operator=(const mjCBodyPair& other); mjCBodyPair& operator=(const mjCBodyPair& other);
@@ -1506,7 +1506,7 @@ class mjCEquality : public mjCEquality_, private mjsEquality {
friend class mjXWriter; friend class mjXWriter;
public: public:
mjCEquality(mjCModel* = 0, mjCDef* = 0); explicit mjCEquality(mjCModel* = 0, mjCDef* = 0);
mjCEquality(const mjCEquality& other); mjCEquality(const mjCEquality& other);
mjCEquality& operator=(const mjCEquality& other); mjCEquality& operator=(const mjCEquality& other);
@@ -1545,7 +1545,7 @@ class mjCTendon : public mjCTendon_, private mjsTendon {
friend class mjXWriter; friend class mjXWriter;
public: public:
mjCTendon(mjCModel* = nullptr, mjCDef* = nullptr); explicit mjCTendon(mjCModel* = nullptr, mjCDef* = nullptr);
mjCTendon(const mjCTendon& other); mjCTendon(const mjCTendon& other);
mjCTendon& operator=(const mjCTendon& other); mjCTendon& operator=(const mjCTendon& other);
~mjCTendon(); ~mjCTendon();
@@ -1641,7 +1641,7 @@ class mjCPlugin : public mjCPlugin_ {
friend class mjXWriter; friend class mjXWriter;
public: public:
mjCPlugin(mjCModel*); explicit mjCPlugin(mjCModel*);
mjCPlugin(const mjCPlugin& other); mjCPlugin(const mjCPlugin& other);
mjCPlugin& operator=(const mjCPlugin& other); mjCPlugin& operator=(const mjCPlugin& other);
@@ -1689,7 +1689,7 @@ class mjCActuator : public mjCActuator_, private mjsActuator {
friend class mjXWriter; friend class mjXWriter;
public: public:
mjCActuator(mjCModel* = nullptr, mjCDef* = nullptr); explicit mjCActuator(mjCModel* = nullptr, mjCDef* = nullptr);
mjCActuator(const mjCActuator& other); mjCActuator(const mjCActuator& other);
mjCActuator& operator=(const mjCActuator& other); mjCActuator& operator=(const mjCActuator& other);
@@ -1750,7 +1750,7 @@ class mjCSensor : public mjCSensor_, private mjsSensor {
friend class mjXWriter; friend class mjXWriter;
public: public:
mjCSensor(mjCModel*); explicit mjCSensor(mjCModel*);
mjCSensor(const mjCSensor& other); mjCSensor(const mjCSensor& other);
mjCSensor& operator=(const mjCSensor& other); mjCSensor& operator=(const mjCSensor& other);
@@ -1791,7 +1791,7 @@ class mjCNumeric : public mjCNumeric_, private mjsNumeric {
friend class mjXWriter; friend class mjXWriter;
public: public:
mjCNumeric(mjCModel*); explicit mjCNumeric(mjCModel*);
mjCNumeric(const mjCNumeric& other); mjCNumeric(const mjCNumeric& other);
mjCNumeric& operator=(const mjCNumeric& other); mjCNumeric& operator=(const mjCNumeric& other);
~mjCNumeric(); ~mjCNumeric();
@@ -1823,7 +1823,7 @@ class mjCText : public mjCText_, private mjsText {
friend class mjXWriter; friend class mjXWriter;
public: public:
mjCText(mjCModel*); explicit mjCText(mjCModel*);
mjCText(const mjCText& other); mjCText(const mjCText& other);
mjCText& operator=(const mjCText& other); mjCText& operator=(const mjCText& other);
~mjCText(); ~mjCText();
@@ -1860,7 +1860,7 @@ class mjCTuple : public mjCTuple_, private mjsTuple {
friend class mjXWriter; friend class mjXWriter;
public: public:
mjCTuple(mjCModel*); explicit mjCTuple(mjCModel*);
mjCTuple(const mjCTuple& other); mjCTuple(const mjCTuple& other);
mjCTuple& operator=(const mjCTuple& other); mjCTuple& operator=(const mjCTuple& other);
~mjCTuple(); ~mjCTuple();
@@ -1904,7 +1904,7 @@ class mjCKey : public mjCKey_, private mjsKey {
friend class mjXWriter; friend class mjXWriter;
public: public:
mjCKey(mjCModel*); explicit mjCKey(mjCModel*);
mjCKey(const mjCKey& other); mjCKey(const mjCKey& other);
mjCKey& operator=(const mjCKey& other); mjCKey& operator=(const mjCKey& other);
~mjCKey(); ~mjCKey();
@@ -1930,7 +1930,7 @@ class mjCDef : public mjsElement {
public: public:
mjCDef(); mjCDef();
mjCDef(mjCModel*); explicit mjCDef(mjCModel*);
mjCDef(const mjCDef& other); mjCDef(const mjCDef& other);
mjCDef& operator=(const mjCDef& other); mjCDef& operator=(const mjCDef& other);
mjCDef& operator+=(const mjCDef& other); mjCDef& operator+=(const mjCDef& other);