Sketcher: GeoEnum and GeoListId constant reference outside the translation unit

================================================================================

GeoEnum static members are used in constexpr in GeoListId.

Previous code worked because the static members where inside the same translation unit.

This code:
1. Declares the static members to use them as constant expressions with the value
2. Definition of the static members (odr-used) shall not contain an initializer.
This commit is contained in:
Abdullah Tahiri
2021-12-14 16:16:23 +01:00
committed by abdullahtahiriyo
parent c7d419623c
commit 2f77d3bc95
2 changed files with 14 additions and 14 deletions

View File

@@ -26,15 +26,11 @@
using namespace Sketcher;
const int GeoEnum::RtPnt = -1;
const int GeoEnum::HAxis = -1;
const int GeoEnum::VAxis = -2;
const int GeoEnum::RefExt = -3;
const int GeoEnum::GeoUndef = -2000;
constexpr const GeoElementId GeoElementId::RtPnt = GeoElementId(GeoEnum::RtPnt, PointPos::start);
constexpr const GeoElementId GeoElementId::HAxis = GeoElementId(GeoEnum::HAxis, PointPos::none);
constexpr const GeoElementId GeoElementId::VAxis = GeoElementId(GeoEnum::VAxis, PointPos::end);
const int GeoEnum::RtPnt;
const int GeoEnum::HAxis;
const int GeoEnum::VAxis;
const int GeoEnum::RefExt;
const int GeoEnum::GeoUndef;
bool GeoElementId::operator==(const GeoElementId& obj) const
{

View File

@@ -63,11 +63,11 @@ namespace Sketcher
*/
struct SketcherExport GeoEnum
{
static const int RtPnt; // GeoId of the Root Point
static const int HAxis; // GeoId of the Horizontal Axis
static const int VAxis; // GeoId of the Vertical Axis
static const int RefExt; // Starting GeoID of external geometry (negative geoIds starting at this index)
static const int GeoUndef; // GeoId of an undefined Geometry (uninitialised or unused GeoId)
static const int RtPnt = -1; // GeoId of the Root Point
static const int HAxis = -1; // GeoId of the Horizontal Axis
static const int VAxis = -2; // GeoId of the Vertical Axis
static const int RefExt = -3; // Starting GeoID of external geometry ( negative geoIds starting at this index)
static const int GeoUndef = -2000; // GeoId of an undefined Geometry (uninitialised or unused GeoId)
};
/*!
@@ -134,6 +134,10 @@ constexpr GeoElementId::GeoElementId(int geoId, PointPos pos): GeoId(geoId), Pos
{
}
constexpr const GeoElementId GeoElementId::RtPnt = GeoElementId(GeoEnum::RtPnt, PointPos::start);
constexpr const GeoElementId GeoElementId::HAxis = GeoElementId(GeoEnum::HAxis, PointPos::none);
constexpr const GeoElementId GeoElementId::VAxis = GeoElementId(GeoEnum::VAxis, PointPos::end);
} // namespace Sketcher
namespace std