Possibility to build OCCT using Visual Studio 2008 (VC9) is restored.
For that:
- template functions and classes from namespace std or tr1 (for VC9) are imported to namespace opencascade which is then used instead of std in relevant places
- templates not provided by compiler (VC9) but required for OCCT are defined in this namespace (in Standard_Handle.hxx)
- methods implementing move semantics are excluded for VC9 compiler (which does not support && syntax)
- support of vc9 compiler is restored in build procedures and environment scripts
- check of type of the current class in macros DEFINE_STANDARD_RTTI* is refactored
VS 2008 is restored in the list of supported platforms on Overview / System Requirements.
if not "%DevEnvDir%" == "" (
rem If DevEnvDir is already defined (e.g. in custom.bat), use that value
+) else if /I "%VCFMT%" == "vc9" (
+ set "DevEnvDir=%VS90COMNTOOLS%..\IDE"
) else if /I "%VCFMT%" == "vc10" (
set "DevEnvDir=%VS100COMNTOOLS%..\IDE"
) else if /I "%VCFMT%" == "vc11" (
) else if /I "%VCFMT%" == "gcc" (
rem MinGW
) else (
- echo Error: wrong VS identifier
+ echo Error: first argument ^(%VCVER%^) should specify supported version of Visual C++,
+ echo one of:
+ echo vc9 = VS 2008 ^(SP1^)
+ echo vc10 = VS 2010 ^(SP3^)
+ echo vc11 = VS 2012 ^(SP3^)
+ echo vc12 = VS 2013 ^(SP3^)
+ echo vc14 = VS 2015
+ echo vc141 = VS 2017
exit /B
)
rem ----- Parsing vcvarsall for qt samples and define PlatformToolset -----
-if /I "%VCFMT%" == "vc10" (
+if /I "%VCFMT%" == "vc9" (
+ set "VCVARS=%VS90COMNTOOLS%..\..\VC\vcvarsall.bat"
+ set "VCPlatformToolSet=v90"
+) else if /I "%VCFMT%" == "vc10" (
set "VCVARS=%VS100COMNTOOLS%..\..\VC\vcvarsall.bat"
set "VCPlatformToolSet=v100"
) else if /I "%VCFMT%" == "vc11" (
) else if /I "%VCFMT%" == "gcc" (
rem MinGW
) else (
- echo Error: first argument ^(%VCVER%^) should specify supported version of Visual C++,
- echo one of: vc10 ^(VS 2010 SP3^), vc11 ^(VS 2012 SP3^), vc12 ^(VS 2013^) or vc14 ^(VS 2015^)
- exit
+ echo Error: wrong VS identifier
+ exit /B
)
set "CSF_OPT_LIB32D=%CSF_OPT_LIB32%"
if not "%DevEnvDir%" == "" (
rem If DevEnvDir is already defined (e.g. in custom.bat), use that value
+) else if /I "%VCFMT%" == "vc9" (
+ set "DevEnvDir=%VS90COMNTOOLS%..\IDE"
) else if /I "%VCFMT%" == "vc10" (
set "DevEnvDir=%VS100COMNTOOLS%..\IDE"
) else if /I "%VCFMT%" == "vc11" (
)
rem ----- Parsing vcvarsall for qt samples and define PlatformToolset -----
-if /I "%VCFMT%" == "vc10" (
+if /I "%VCFMT%" == "vc9" (
+ set "VCVARS=%VS90COMNTOOLS%..\..\VC\vcvarsall.bat"
+ set "VCPlatformToolSet=v90"
+) else if /I "%VCFMT%" == "vc10" (
set "VCVARS=%VS100COMNTOOLS%..\..\VC\vcvarsall.bat"
set "VCPlatformToolSet=v100"
) else if /I "%VCFMT%" == "vc11" (
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
- ManagedExtensions="0"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
- ManagedExtensions="0"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
| OS | Compiler |
| --------- | ----------- |
-| Windows | Microsoft Visual Studio: 2010 SP1<sup>1</sup>, 2012 Update 4, 2013 Update 5, 2015, 2017 <br> Intel C++ Composer XE 2013 SP1 <br> GCC 4.3+ (Mingw-w64)|
+| Windows | Microsoft Visual Studio: 2008 SP1, 2010 SP1<sup>1</sup>, 2012 Update 4, 2013 Update 5, 2015, 2017 <br> GCC 4.3+ (Mingw-w64)|
| Linux | GNU gcc 4.3+ <br> LLVM CLang 3.6+ |
-| OS X | XCode 6 or newer |
+| OS X / macOS | XCode 6 or newer |
| Android | NDK r10, GNU gcc 4.8 or newer |
1) VC++ 10 64-bit is used for regular testing and for building
{
const std::pair<int, int> aNode = aQueue.front();
- BVH::Array<T, N>::Append (aQBVH->myMinPointBuffer, BVH::Array<T, N>::Value (this->myMinPointBuffer, std::get<0> (aNode)));
- BVH::Array<T, N>::Append (aQBVH->myMaxPointBuffer, BVH::Array<T, N>::Value (this->myMaxPointBuffer, std::get<0> (aNode)));
+ BVH::Array<T, N>::Append (aQBVH->myMinPointBuffer, BVH::Array<T, N>::Value (this->myMinPointBuffer, opencascade::std::get<0> (aNode)));
+ BVH::Array<T, N>::Append (aQBVH->myMaxPointBuffer, BVH::Array<T, N>::Value (this->myMaxPointBuffer, opencascade::std::get<0> (aNode)));
BVH_Vec4i aNodeInfo;
- if (this->IsOuter (std::get<0> (aNode))) // is leaf node
+ if (this->IsOuter (opencascade::std::get<0> (aNode))) // is leaf node
{
aNodeInfo = BVH_Vec4i (1 /* leaf flag */,
- this->BegPrimitive (std::get<0> (aNode)), this->EndPrimitive (std::get<0> (aNode)), std::get<1> (aNode) /* level */);
+ this->BegPrimitive (opencascade::std::get<0> (aNode)), this->EndPrimitive (opencascade::std::get<0> (aNode)), opencascade::std::get<1> (aNode) /* level */);
}
else
{
NCollection_Vector<int> aGrandChildNodes;
- const int aLftChild = Child<0> (std::get<0> (aNode));
- const int aRghChild = Child<1> (std::get<0> (aNode));
+ const int aLftChild = Child<0> (opencascade::std::get<0> (aNode));
+ const int aRghChild = Child<1> (opencascade::std::get<0> (aNode));
if (this->IsOuter (aLftChild)) // is leaf node
{
aGrandChildNodes.Append (aLftChild);
for (int aNodeIdx = 0; aNodeIdx < aGrandChildNodes.Size(); ++aNodeIdx)
{
- aQueue.push_back (std::make_pair (aGrandChildNodes (aNodeIdx), std::get<1> (aNode) + 1));
+ aQueue.push_back (std::make_pair (aGrandChildNodes (aNodeIdx), opencascade::std::get<1> (aNode) + 1));
}
aNodeInfo = BVH_Vec4i (0 /* inner flag */,
- aNbNodes, aGrandChildNodes.Size() - 1, std::get<1> (aNode) /* level */);
+ aNbNodes, aGrandChildNodes.Size() - 1, opencascade::std::get<1> (aNode) /* level */);
- aQBVH->myDepth = Max (aQBVH->myDepth, std::get<1> (aNode) + 1);
+ aQBVH->myDepth = Max (aQBVH->myDepth, opencascade::std::get<1> (aNode) + 1);
aNbNodes += aGrandChildNodes.Size();
}
if (Size (theArray) == theCount)
{
#ifdef _STD_VECTOR_SHRINK
+
+#if(defined(_MSC_VER) && (_MSC_VER < 1600))
+ BVH_ArrayNt aTmpArray(theArray);
+ theArray.swap(aTmpArray);
+#else
theArray.shrink_to_fit();
+#endif
+
#endif
}
else
for (; anIterS.More(); anIterS.Next()) {
BinLDrivers_DocumentSection& aCurSection = anIterS.ChangeValue();
if (aCurSection.IsPostRead() == Standard_False) {
- theIStream.seekg ((streampos) aCurSection.Offset());
+ theIStream.seekg ((std::streamsize)aCurSection.Offset());
if (aCurSection.Name().IsEqual ((Standard_CString)SHAPESECTION_POS))
ReadShapeSection (aCurSection, theIStream);
else
for (; aSectIter.More(); aSectIter.Next()) {
BinLDrivers_DocumentSection& aCurSection = aSectIter.ChangeValue();
if (aCurSection.IsPostRead()) {
- theIStream.seekg ((streampos) aCurSection.Offset());
+ theIStream.seekg ((std::streamsize)aCurSection.Offset());
ReadSection (aCurSection, theDoc, theIStream);
}
}
const uint64_t theOffset)
{
const uint64_t aSectionEnd = (uint64_t) theStream.tellp();
- theStream.seekp(myValue[0]);
+ theStream.seekp((std::streamsize)myValue[0]);
myValue[0] = theOffset;
myValue[1] = aSectionEnd - theOffset;
uint64_t aVal[3] = {
#endif
theStream.write((char *)&aVal[0], 3*sizeof(uint64_t));
- theStream.seekp(aSectionEnd);
+ theStream.seekp((std::streamsize)aSectionEnd);
}
//=======================================================================
//! isSenseMarker indicates whether to render the
//! sense glyph (arrow) for curves or not
Standard_EXPORT static void Set (const Standard_CString Name, const Handle(Geom_Geometry)& G, const Standard_Boolean isSenseMarker = Standard_True);
-template <class T> static void Set (const Standard_CString Name, const Handle(T)& Arg, typename std::enable_if<std::is_base_of<Geom_Geometry, T>::value>::type * = 0) { Set (Name, (const Handle(Geom_Geometry)&)Arg); }
+template <class T> static void Set (const Standard_CString Name, const Handle(T)& Arg, typename opencascade::std::enable_if<opencascade::std::is_base_of<Geom_Geometry, T>::value>::type * = 0) { Set (Name, (const Handle(Geom_Geometry)&)Arg); }
//! Sets <C> in the variable <Name>. Overwrite the
//! variable if already set.
//! isSenseMarker indicates whether to render the
//! sense glyph (arrow) for curves or not
Standard_EXPORT static void Set (const Standard_CString Name, const Handle(Geom2d_Curve)& C, const Standard_Boolean isSenseMarker = Standard_True);
-template <class T> static void Set (const Standard_CString Name, const Handle(T)& Arg, typename std::enable_if<std::is_base_of<Geom2d_Curve, T>::value>::type * = 0) { Set (Name, (const Handle(Geom2d_Curve)&)Arg); }
+template <class T> static void Set (const Standard_CString Name, const Handle(T)& Arg, typename opencascade::std::enable_if<opencascade::std::is_base_of<Geom2d_Curve, T>::value>::type * = 0) { Set (Name, (const Handle(Geom2d_Curve)&)Arg); }
//! Sets <T> in the variable <Name>. Overwrite the
//! variable if already set.
//! classes derived from IGESData_IGESEntity, for VC++ 10 and 11 compillers
template <class T>
void Send (const Handle(T)& val, Standard_Boolean negative = Standard_False,
- typename std::enable_if<std::is_base_of<IGESData_IGESEntity, T>::value>::type * = 0)
+ typename opencascade::std::enable_if<opencascade::std::is_base_of<IGESData_IGESEntity, T>::value>::type * = 0)
{
Send ((const Handle(IGESData_IGESEntity)&)val, negative);
}
}
//! Move constructor
+#if(defined(_MSC_VER) && (_MSC_VER < 1600))
+#else
NCollection_Array1 (NCollection_Array1&& theOther)
: myLowerBound (theOther.myLowerBound),
myUpperBound (theOther.myUpperBound),
theOther.myDeletable = false;
theOther.myData = NULL;
}
+#endif
//! C array-based constructor
NCollection_Array1 (const TheItemType& theBegin,
}
//! Move assignment
- NCollection_Array1& Move (NCollection_Array1&& theOther)
+ NCollection_Array1& Move (NCollection_Array1& theOther)
{
if (&theOther == this)
{
}
//! Move assignment operator.
+#if(defined(_MSC_VER) && (_MSC_VER < 1600))
+#else
NCollection_Array1& operator= (NCollection_Array1&& theOther)
{
- return Move (std::move (theOther));
+ return Move (theOther);
}
+#endif
//! @return first element
const TheItemType& First() const
_SequenceType_& ChangeSequence () { return *this; } \
template <class T> \
void Append (const Handle(T)& theOther, \
- typename std::enable_if<std::is_base_of<HClassName, T>::value>::type * = 0) { \
+ typename opencascade::std::enable_if<opencascade::std::is_base_of<HClassName, T>::value>::type * = 0) { \
_SequenceType_::Append (theOther->ChangeSequence()); \
} \
DEFINE_STANDARD_RTTI_INLINE(HClassName,Standard_Transient) \
//! The intent is similar to std::make_shared<> in STL, except that this
//! implementation defines a separate type.
-template <class T, typename = typename std::enable_if<! std::is_base_of<Standard_Transient, T>::value>::type>
+template <class T, typename = typename opencascade::std::enable_if<! opencascade::std::is_base_of<Standard_Transient, T>::value>::type>
class NCollection_Shared : public Standard_Transient, public T
{
public:
#include <Standard_Assert.hxx>
#include <iterator>
-// This file uses C++11 utilities like std::is_base<>, which are not
-// available in some environments (e.g. MSVC includes them since VS 2008).
-// Hence here we define our own implementation of these tools in namespace opencascade.
-// When all compilers support this, this namespace can be removed and replaced by std.
-namespace opencascade
-{
- template<bool Condition, typename T>
- struct enable_if
- {
- typedef T type;
- };
-
- template<typename T>
- struct enable_if<false, T>
- {
- };
-
- template<typename T1, typename T2>
- struct is_same
- {
- enum { value = 0 };
- };
-
- template<typename T>
- struct is_same<T, T>
- {
- enum { value = 1 };
- };
-
- template<bool Condition, typename TypeTrue, typename TypeFalse>
- struct conditional
- {
- typedef TypeTrue type;
- };
-
- template<typename TypeTrue, typename TypeFalse>
- struct conditional<false, TypeTrue, TypeFalse>
- {
- typedef TypeFalse type;
- };
-}
-
//! Helper class that allows to use NCollection iterators as STL iterators.
//! NCollection iterator can be extended to STL iterator of any category by
//! adding necessary methods: STL forward iterator requires IsEqual method,
template<class Category, class BaseIterator, class ItemType, bool IsConstant>
class NCollection_StlIterator :
public std::iterator<Category, ItemType, ptrdiff_t,
- typename opencascade::conditional<IsConstant, const ItemType*, ItemType*>::type,
- typename opencascade::conditional<IsConstant, const ItemType&, ItemType&>::type>
+ typename opencascade::std::conditional<IsConstant, const ItemType*, ItemType*>::type,
+ typename opencascade::std::conditional<IsConstant, const ItemType&, ItemType&>::type>
{
public:
// an appropriate method based on template arguments (at instantiation time).
template<bool Condition>
- typename opencascade::enable_if<!Condition, ItemType&>::type Reference() const
+ typename opencascade::std::enable_if<!Condition, ItemType&>::type Reference() const
{
return myIterator.ChangeValue();
}
template<bool Condition>
- typename opencascade::enable_if<Condition, const ItemType&>::type Reference() const
+ typename opencascade::std::enable_if<Condition, const ItemType&>::type Reference() const
{
return myIterator.Value();
}
//! Prefix decrement
NCollection_StlIterator& operator--()
{
- Standard_STATIC_ASSERT((opencascade::is_same<std::bidirectional_iterator_tag,Category>::value ||
- opencascade::is_same<std::random_access_iterator_tag,Category>::value));
+ Standard_STATIC_ASSERT((opencascade::std::is_same<std::bidirectional_iterator_tag,Category>::value ||
+ opencascade::std::is_same<std::random_access_iterator_tag,Category>::value));
myIterator.Previous();
return *this;
}
//! Move forward
NCollection_StlIterator& operator+= (typename NCollection_StlIterator::difference_type theOffset)
{
- Standard_STATIC_ASSERT((opencascade::is_same<std::random_access_iterator_tag,Category>::value));
+ Standard_STATIC_ASSERT((opencascade::std::is_same<std::random_access_iterator_tag,Category>::value));
myIterator.Offset (theOffset);
return *this;
}
//! Difference
typename NCollection_StlIterator::difference_type operator- (const NCollection_StlIterator& theOther) const
{
- Standard_STATIC_ASSERT((opencascade::is_same<std::random_access_iterator_tag,Category>::value));
+ Standard_STATIC_ASSERT((opencascade::std::is_same<std::random_access_iterator_tag,Category>::value));
return myIterator.Differ (theOther.myIterator);
}
UBTree& myTree;
NCollection_Vector<ObjBnd> mySeqPtr;
- std::mt19937 myRandGen; //!< random number generator
+ opencascade::std::mt19937 myRandGen; //!< random number generator
Standard_Boolean myIsFullRandom;
};
{
return;
}
- auto& aRes = mySharedResources->Find (theKey);
+ const Handle(OpenGl_Resource)& aRes = mySharedResources->Find (theKey);
if (aRes->GetRefCount() > 1)
{
return;
continue;
}
- auto& aRes = mySharedResources->ChangeFind (aKey);
+ const Handle(OpenGl_Resource)& aRes = mySharedResources->ChangeFind (aKey);
if (aRes->GetRefCount() > 1)
{
// should be only 1 instance in mySharedResources
const Standard_Integer aNbAdjs = 6 * nbTriangles;
if (myTriangles.Size() != nbNodes)
{
- TColStd_Array1OfInteger aTriArray (1, nbNodes);
- myTriangles.Move (std::move (aTriArray));
+ myTriangles.Resize (1, nbNodes, Standard_False);
}
if (myAdjacents.Size() != aNbAdjs)
{
- TColStd_Array1OfInteger anAdjArray (1, aNbAdjs);
- myAdjacents.Move (std::move (anAdjArray));
+ myAdjacents.Resize (1, aNbAdjs, Standard_False);
}
}
}
Handle(Standard_Transient) aHandle = new Standard_Transient();
- std::shared_ptr<Standard_Transient> aSharePtr (new Standard_Transient());
+ opencascade::std::shared_ptr<Standard_Transient> aSharePtr (new Standard_Transient());
theDI << "Time of creating and destroying " << aNbIters << " smart pointers to the same object, per item, ns:";
{
{
{
QATimer aTimer (theDI, "\nC++ shared_ptr: ", QATimer::ns, aNbIters);
{
- std::vector< std::shared_ptr<Standard_Transient> > aSharePointers (aNbIters);
+ std::vector< opencascade::std::shared_ptr<Standard_Transient> > aSharePointers (aNbIters);
for (Standard_Integer anIter = 0; anIter < aNbIters; ++anIter)
{
aSharePointers[anIter] = aSharePtr;
const int64_t aEndPos = (theUntilPos > 0 ? 1 + GETPOS(theUntilPos) : std::numeric_limits<int64_t>::max());
// skip header "solid ..."
- theStream.ignore (aEndPos - aStartPos, '\n');
+ theStream.ignore ((std::streamsize)(aEndPos - aStartPos), '\n');
if (!theStream)
{
Message::DefaultMessenger()->Send ("Error: premature end of file", Message_Fail);
// report progress every 1 MiB of read data
const int aStepB = 1024 * 1024;
- const Standard_Integer aNbSteps = 1 + Standard_Integer((theUntilPos - aStartPos) / aStepB);
+ const Standard_Integer aNbSteps = 1 + Standard_Integer((GETPOS(theUntilPos) - aStartPos) / aStepB);
Message_ProgressSentry aPSentry (theProgress, "Reading text STL file", 0, aNbSteps, 1);
int64_t aProgressPos = aStartPos + aStepB;
}
char facet[LINELEN], outer[LINELEN];
- theStream.getline (facet, std::min (LINELEN, aEndPos - GETPOS(theStream.tellg()))); // "facet normal nx ny nz"
+ theStream.getline (facet, (std::streamsize)std::min (LINELEN, aEndPos - GETPOS(theStream.tellg()))); // "facet normal nx ny nz"
if (str_starts_with (facet, "endsolid", 8))
{
// end of STL code
break;
}
- theStream.getline (outer, std::min (LINELEN, aEndPos - GETPOS(theStream.tellg()))); // "outer loop"
+ theStream.getline (outer, (std::streamsize)std::min (LINELEN, aEndPos - GETPOS(theStream.tellg()))); // "outer loop"
if (!str_starts_with (facet, "facet", 5) || !str_starts_with (outer, "outer", 5))
{
TCollection_AsciiString aStr ("Error: unexpected format of facet at line ");
return false;
}
- theStream.getline (aLine1, std::min (LINELEN, aEndPos - GETPOS(theStream.tellg())));
- theStream.getline (aLine2, std::min (LINELEN, aEndPos - GETPOS(theStream.tellg())));
- theStream.getline (aLine3, std::min (LINELEN, aEndPos - GETPOS(theStream.tellg())));
+ theStream.getline (aLine1, (std::streamsize)std::min (LINELEN, aEndPos - GETPOS(theStream.tellg())));
+ theStream.getline (aLine2, (std::streamsize)std::min (LINELEN, aEndPos - GETPOS(theStream.tellg())));
+ theStream.getline (aLine3, (std::streamsize)std::min (LINELEN, aEndPos - GETPOS(theStream.tellg())));
// stop reading if end of file is reached;
// note that well-formatted file never ends by the vertex line
AddTriangle (n1, n2, n3);
}
- theStream.ignore (aEndPos - GETPOS(theStream.tellg()), '\n'); // skip "endloop"
- theStream.ignore (aEndPos - GETPOS(theStream.tellg()), '\n'); // skip "endfacet"
+ theStream.ignore ((std::streamsize)(aEndPos - GETPOS(theStream.tellg())), '\n'); // skip "endloop"
+ theStream.ignore ((std::streamsize)(aEndPos - GETPOS(theStream.tellg())), '\n'); // skip "endfacet"
aNbLine += 2;
}
#include <fstream>
+// Suppress VC9 warning on xsputn() function
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable: 4996)
+#endif
+
//! Custom buffer object implementing STL interface std::streambuf for streamed reading from allocated memory block.
//! Implements minimal sub-set of methods for passing buffer to std::istream, including seek support.
//!
};
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
#endif // _Standard_ArrayStreamBuffer_HeaderFile
class Standard_Transient;
+//! Namespace opencascade is intended for low-level template classes and functions
namespace opencascade {
+ //! Namespace opencascade::std includes templates from C++11 std namespace used by
+ //! OCCT classes. These definitions are imported from std namespace, plus (on older
+ //! compilers) from std::tr1, or implemented by custom code where neither std
+ //! not std::tr1 provide necessary definitions.
+ namespace std
+ {
+ // import all available standard stuff from std namespace
+ using namespace ::std;
+
+// for old MSVC compiler, some standard templates are defined in std::tr1 namespace,
+// and some missing ones are implemented here
+#if(defined(_MSC_VER) && (_MSC_VER < 1600))
+ using namespace ::std::tr1;
+
+ // C++11 template class enable_if
+ template<bool Test, class Type = void>
+ struct enable_if
+ {// type is undefined for assumed !_Test
+ };
+
+ template<class _Type>
+ struct enable_if<true, _Type>
+ {// type is _Type for _Test
+ typedef _Type type;
+ };
+
+ template<bool Condition, typename TypeTrue, typename TypeFalse>
+ struct conditional
+ {
+ typedef TypeTrue type;
+ };
+
+ template<typename TypeTrue, typename TypeFalse>
+ struct conditional<false, TypeTrue, TypeFalse>
+ {
+ typedef TypeFalse type;
+ };
+
+#endif
+
+ } // namespace opencascade::std
+
//! Trait yielding true if class T1 is base of T2 but not the same
template <class T1, class T2, class Dummy = void>
- struct is_base_but_not_same : std::is_base_of <T1, T2> {};
+ struct is_base_but_not_same : opencascade::std::is_base_of <T1, T2> {};
//! Explicit specialization of is_base_of trait to workaround the
//! requirement of type to be complete when T1 and T2 are the same.
template <class T1, class T2>
- struct is_base_but_not_same <T1, T2, typename std::enable_if <std::is_same <T1, T2>::value>::type> : std::false_type {};
+ struct is_base_but_not_same <T1, T2, typename opencascade::std::enable_if <opencascade::std::is_same <T1, T2>::value>::type> : opencascade::std::false_type {};
//! Intrusive smart pointer for use with Standard_Transient class and its descendants.
//!
BeginScope();
}
+#if(defined(_MSC_VER) && (_MSC_VER < 1600))
+#else
//! Move constructor
handle (handle&& theHandle) : entity(theHandle.entity)
{
theHandle.entity = 0;
}
+#endif
//! Destructor
~handle ()
return *this;
}
+#if(defined(_MSC_VER) && (_MSC_VER < 1600))
+#else
//! Move operator
handle& operator= (handle&& theHandle)
{
std::swap (this->entity, theHandle.entity);
return *this;
}
+#endif
//! STL-like cast to pointer to referred object (note non-const).
//! @sa std::shared_ptr::get()
//! Down casting operator from handle to base type
template <class T2>
- static typename std::enable_if<is_base_but_not_same<T2, T>::value, handle>::type
+ static typename opencascade::std::enable_if<is_base_but_not_same<T2, T>::value, handle>::type
DownCast (const handle<T2>& theObject)
{
return handle (dynamic_cast<T*>(const_cast<T2*>(theObject.get())));
//! Down casting operator from pointer to base type
template <class T2>
- static typename std::enable_if<is_base_but_not_same<T2, T>::value, handle>::type
+ static typename opencascade::std::enable_if<is_base_but_not_same<T2, T>::value, handle>::type
DownCast (const T2* thePtr)
{
return handle (dynamic_cast<T*>(const_cast<T2*>(thePtr)));
//! For compatibility, define down casting operator from non-base type, as deprecated
template <class T2>
Standard_DEPRECATED("down-casting from object of the same or unrelated type is meaningless")
- static handle DownCast (const handle<T2>& theObject, typename std::enable_if<!is_base_but_not_same<T2, T>::value, void*>::type = 0)
+ static handle DownCast (const handle<T2>& theObject, typename opencascade::std::enable_if<!is_base_but_not_same<T2, T>::value, void*>::type = 0)
{
return handle (dynamic_cast<T*>(const_cast<T2*>(theObject.get())));
}
//! For compatibility, define down casting operator from non-base type, as deprecated
template <class T2>
Standard_DEPRECATED("down-casting from object of the same or unrelated type is meaningless")
- static handle DownCast (const T2* thePtr, typename std::enable_if<!is_base_but_not_same<T2, T>::value, void*>::type = 0)
+ static handle DownCast (const T2* thePtr, typename opencascade::std::enable_if<!is_base_but_not_same<T2, T>::value, void*>::type = 0)
{
return handle (dynamic_cast<T*>(const_cast<T2*>(thePtr)));
}
BeginScope();
}
+#if(defined(_MSC_VER) && (_MSC_VER < 1600))
+#else
//! Generalized move constructor
template <class T2>
handle (handle<T2>&& theHandle, typename std::enable_if <is_base_but_not_same <T, T2>::value>::type* = nullptr)
{
theHandle.entity = 0;
}
+#endif
//! Generalized assignment operator.
template <class T2>
return *this;
}
+#if(defined(_MSC_VER) && (_MSC_VER < 1600))
+#else
//! Generalized move operator
template <class T2>
handle& operator= (handle<T2>&& theHandle)
std::swap (this->entity, theHandle.entity);
return *this;
}
+#endif
#else
{
// error "type is not a member of enable_if" will be generated if T2 is not sub-type of T
// (handle is being cast to const& to handle of non-base type)
- return reinterpret_cast<typename std::enable_if<is_base_but_not_same<T2, T>::value, const handle<T2>&>::type>(*this);
+ return reinterpret_cast<typename opencascade::std::enable_if<is_base_but_not_same<T2, T>::value, const handle<T2>&>::type>(*this);
}
//! Upcast to non-const reference to base type.
{
// error "type is not a member of enable_if" will be generated if T2 is not sub-type of T
// (handle is being cast to const& to handle of non-base type)
- return reinterpret_cast<typename std::enable_if<is_base_but_not_same<T2, T>::value, handle<T2>&>::type>(*this);
+ return reinterpret_cast<typename opencascade::std::enable_if<is_base_but_not_same<T2, T>::value, handle<T2>&>::type>(*this);
}
#endif /* OCCT_HANDLE_NOCAST */
// Auxiliary tools to check at compile time that class declared as base in
// DEFINE_STANDARD_RTTI* macro is actually a base class.
-// For GCC 4.7+, more strict check is possible -- ensuring that base class
-// is direct base -- using non-standard C++ reflection functionality.
#if ! defined(OCC_CHECK_BASE_CLASS)
+
#if (defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || (__GNUC__ > 4)))
+// For GCC 4.7+, more strict check is possible -- ensuring that base class
+// is direct base -- using non-standard C++ reflection functionality.
+
#include <tr2/type_traits>
#include <tuple>
#define OCC_CHECK_BASE_CLASS(Class,Base) \
using direct_base_classes = opencascade::direct_base_class_as_tuple<std::tr2::direct_bases<Class>::type>::type; \
- static_assert(opencascade::has_type<Base, direct_base_classes>::type::value, "OCCT RTTI definition is incorrect: " #Base " is not direct base class of " #Class);
+ static_assert(opencascade::has_type<Base, direct_base_classes>::type::value, "OCCT RTTI definition is incorrect: " #Base " is not direct base class of " #Class); \
+ static_assert(&get_type_name == &Class::get_type_name, "OCCT RTTI definition is misplaced: current class is not " #Class);
+
+#elif (defined(_MSC_VER) && (_MSC_VER < 1600))
+
+// VC9 does not support static_assert and decltype at all
+#define OCC_CHECK_BASE_CLASS(Class,Base)
-#else /* ! GCC 4.7+ */
+#elif (defined(_MSC_VER) && (_MSC_VER >= 1900))
+// VC14+ allow using address of member functions in static checks,
+// that allows checking for the current type being correctly named in the macro
+#define OCC_CHECK_BASE_CLASS(Class,Base) \
+ static_assert(opencascade::is_base_but_not_same<Base, Class>::value, "OCCT RTTI definition is incorrect: " #Base " is not base class of " #Class); \
+ static_assert(&get_type_name == &Class::get_type_name, "OCCT RTTI definition is misplaced: current class is not " #Class);
+
+#else
+
+// by default, check only the base class
#define OCC_CHECK_BASE_CLASS(Class,Base) \
static_assert(opencascade::is_base_but_not_same<Base, Class>::value, "OCCT RTTI definition is incorrect: " #Base " is not base class of " #Class);
-#endif /* GCC 4.7+ */
+#endif
+
#endif /* ! defined(OCC_CHECK_BASE_CLASS) */
//! Helper macro to get instance of a type descriptor for a class in a legacy way.
typedef Base base_type; \
static const char* get_type_name () { return #Class; OCC_CHECK_BASE_CLASS(Class,Base) } \
static const Handle(Standard_Type)& get_type_descriptor () { return Standard_Type::Instance<Class>(); } \
- virtual const Handle(Standard_Type)& DynamicType() const Standard_OVERRIDE { \
- static_assert(std::is_same<const Class*, decltype(this)>::value, "OCCT RTTI definition is misplaced: current class is not " #Class); \
- return get_type_descriptor (); \
- }
+ virtual const Handle(Standard_Type)& DynamicType() const Standard_OVERRIDE { return get_type_descriptor (); }
//! Helper macro to be included in definition of the classes inheriting
//! Standard_Transient to enable use of OCCT RTTI.
//! Defines implementation of type descriptor and DynamicType() function
#define IMPLEMENT_STANDARD_RTTIEXT(Class,Base) \
const Handle(Standard_Type)& Class::get_type_descriptor () { return Standard_Type::Instance<Class>(); } \
- const Handle(Standard_Type)& Class::DynamicType() const { \
- static_assert(std::is_same<const Class*, decltype(this)>::value, "OCCT RTTI definition is misplaced: current class is not " #Class); \
- return STANDARD_TYPE(Class); \
- }
+ const Handle(Standard_Type)& Class::DynamicType() const { return STANDARD_TYPE(Class); }
// forward declaration of type_instance class
namespace opencascade {
#include <cstddef>
#include <ctime>
-#include <stdint.h>
+
+// VC9 does not have stdint.h
+#if(defined(_MSC_VER) && (_MSC_VER < 1600))
+ // old MSVC - hasn't stdint header
+ typedef unsigned __int8 uint8_t;
+ typedef unsigned __int16 uint16_t;
+ typedef unsigned __int32 uint32_t;
+ typedef unsigned __int64 uint64_t;
+
+ typedef __int8 int8_t;
+ typedef __int16 int16_t;
+ typedef __int32 int32_t;
+ typedef __int64 int64_t;
+#else
+ #include <stdint.h>
+#endif
#if(defined(_MSC_VER) && (_MSC_VER < 1800))
// only Visual Studio 2013 (vc12) provides <cinttypes> header
// Unicode primitives, char16_t, char32_t
typedef char Standard_Utf8Char; //!< signed UTF-8 char
typedef unsigned char Standard_Utf8UChar; //!< unsigned UTF-8 char
-#if (defined(__GNUC__) && !defined(__clang__) && ((__GNUC__ == 4 && __GNUC_MINOR__ <= 3) || __GNUC__ < 4))
-// compatibility with old GCC compilers
+#if ((defined(__GNUC__) && !defined(__clang__) && ((__GNUC__ == 4 && __GNUC_MINOR__ <= 3) || __GNUC__ < 4)) || (defined(_MSC_VER) && (_MSC_VER < 1600)))
+// compatibility with old GCC and MSVC compilers
typedef uint16_t Standard_ExtCharacter;
typedef uint16_t Standard_Utf16Char;
typedef uint32_t Standard_Utf32Char;