1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0033117: migration to intel oneTBB 2021.5.0 (c++20 ready)

MSVC 2022/c++20.

After employed c++20 language standard errors of compilation in intel oneTBB occurred.
To get rid of compilation errors proposed moving on actual (2021.5.0) intel oneTBB occ products and occt.

After migration errors of compilation of TKernel and TMath have been occurred...
...Error occurred if using c++20 standard with new oneTBB 2021.5.0.
The error was:
   Error C2672 'tbb::v1::parallel_for_each': no matching overloaded function found TKernel
   could be 'void tbb::detail::d2::parallel_for_each(Iterator,Iterator,const Body &)' TKernel
   'tbb::detail::d2::parallel_for_each': the associated constraints are not satisfied TKernel
Note, that if we use c++14 or c++17, all ok, error does not occures.
To solve the problem, i have to modify `UniversalIterator` class:
`value_type` instead `UniversalIterator` converted to `IteratorInterface*`
`pointer` = `reference` = `value_type`
Method `DownCast` moved into `FunctorInterface` abstract class.
argument `UniversalIterator& item` of the unary fuctions converted to `IteratorInterface*`.
The proposed solution removes compilation error.

Affected projects: TKernel, TMath
Affected sources: src/OSD/OSD_Parallel.hxx, src/OSD/OSD_Parallel_Threads.cxx
Affected classes: class OSD_Parallel, OSD_Parallel::UniversalIterator, OSD_Parallel::FunctorInterface, OSD_Parallel::FunctorWrapperIter, OSD_Parallel:;FunctorWrapperInt.
This commit is contained in:
ddzama
2022-09-15 09:40:48 +03:00
committed by smoskvin
parent b95eefe1c2
commit b3284f3ba9
6 changed files with 210 additions and 245 deletions

View File

@@ -125,10 +125,10 @@ protected:
// Since C++20 inheritance from std::iterator is deprecated, so define predefined types manually:
using iterator_category = std::forward_iterator_tag;
using value_type = UniversalIterator;
using value_type = IteratorInterface*;
using difference_type = ptrdiff_t;
using pointer = UniversalIterator*;
using reference = UniversalIterator&;
using pointer = value_type;
using reference = value_type;
UniversalIterator() {}
@@ -171,18 +171,8 @@ protected:
return aValue;
}
const UniversalIterator& operator* () const { return *this; }
UniversalIterator& operator* () { return *this; }
const UniversalIterator* operator->() const { return this; }
UniversalIterator* operator->() { return this; }
// type cast to actual iterator
template <typename Iterator>
const Iterator& DownCast () const
{
return dynamic_cast<OSD_Parallel::IteratorWrapper<Iterator>*>(myPtr.get())->Value();
}
reference operator* () const { return myPtr.get(); }
reference operator* () { return myPtr.get(); }
private:
std::unique_ptr<IteratorInterface> myPtr;
@@ -196,7 +186,14 @@ protected:
public:
virtual ~FunctorInterface() {}
virtual void operator () (UniversalIterator& theIterator) const = 0;
virtual void operator () (IteratorInterface* theIterator) const = 0;
// type cast to actual iterator
template <typename Iterator>
static const Iterator& DownCast(IteratorInterface* theIterator)
{
return dynamic_cast<OSD_Parallel::IteratorWrapper<Iterator>*>(theIterator)->Value();
}
};
private:
@@ -211,9 +208,9 @@ private:
{
}
virtual void operator() (UniversalIterator& theIterator) const Standard_OVERRIDE
virtual void operator() (IteratorInterface* theIterator) const Standard_OVERRIDE
{
const Iterator& anIt = theIterator.DownCast<Iterator>();
const Iterator& anIt = DownCast<Iterator>(theIterator);
myFunctor(*anIt);
}
@@ -233,9 +230,9 @@ private:
{
}
virtual void operator() (UniversalIterator& theIterator) const Standard_OVERRIDE
virtual void operator() (IteratorInterface* theIterator) const Standard_OVERRIDE
{
Standard_Integer anIndex = theIterator.DownCast<Standard_Integer>();
Standard_Integer anIndex = DownCast<Standard_Integer>(theIterator);
myFunctor(anIndex);
}

View File

@@ -100,7 +100,7 @@ namespace
{
for (OSD_Parallel::UniversalIterator anIter = myRange.It(); anIter != myRange.End(); anIter = myRange.It())
{
myPerformer (anIter);
myPerformer (*anIter);
}
}