[Bf-blender-cvs] [3f5b2950843] master: Freestyle: Fix compilation error with C++17

Sergey Sharybin noreply at git.blender.org
Fri Jun 19 12:03:02 CEST 2020


Commit: 3f5b29508435dd5ace14e3460fa9f51c46e8c64e
Author: Sergey Sharybin
Date:   Thu Jun 18 15:18:26 2020 +0200
Branches: master
https://developer.blender.org/rB3f5b29508435dd5ace14e3460fa9f51c46e8c64e

Freestyle: Fix compilation error with C++17

AutoPtr class became a sub-class of unique_ptr with some special magic
to mimic behavior of auto_ptr for copy constructor.

The code was already there, but for some reason visual studio did not
set __cplusplus correctly for some reason.

The other change is remove of binary function usage, which is not
needed in the Freestyle code.

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

M	source/blender/freestyle/intern/view_map/AutoPtrHelper.h
M	source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp

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

diff --git a/source/blender/freestyle/intern/view_map/AutoPtrHelper.h b/source/blender/freestyle/intern/view_map/AutoPtrHelper.h
index 9da109ab2a6..1a72fe48a2a 100644
--- a/source/blender/freestyle/intern/view_map/AutoPtrHelper.h
+++ b/source/blender/freestyle/intern/view_map/AutoPtrHelper.h
@@ -26,7 +26,6 @@
 
 namespace Freestyle {
 
-#if __cplusplus > 199711L
 template<typename T> class AutoPtr : public std::unique_ptr<T> {
  public:
   AutoPtr() : std::unique_ptr<T>()
@@ -36,26 +35,16 @@ template<typename T> class AutoPtr : public std::unique_ptr<T> {
   {
   }
 
-  /* TODO(sergey): Is there more clear way to do this? */
+  /* Mimmic behavior of legacy auto_ptr.
+   * Keep implementation as small as possible, hense delete assignment oeprator. */
+
   template<typename X> AutoPtr(AutoPtr<X> &other) : std::unique_ptr<T>(other.get())
   {
     other.release();
   }
+
+  template<typename X> AutoPtr& operator=(AutoPtr<X> & other) = delete;
 };
-#else
-template<typename T> class AutoPtr : public std::auto_ptr<T> {
- public:
-  AutoPtr() : std::auto_ptr<T>()
-  {
-  }
-  AutoPtr(T *ptr) : std::auto_ptr<T>(ptr)
-  {
-  }
-  AutoPtr(std::auto_ptr_ref<T> ref) : std::auto_ptr<T>(ref)
-  {
-  }
-};
-#endif
 
 } /* namespace Freestyle */
 
diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
index 40ab3ada777..c3c43ce6722 100644
--- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
+++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
@@ -2273,10 +2273,10 @@ void ViewMapBuilder::ComputeIntersections(ViewMap *ioViewMap,
 #endif
 }
 
-struct less_SVertex2D : public binary_function<SVertex *, SVertex *, bool> {
+struct less_SVertex2D {
   real epsilon;
 
-  less_SVertex2D(real eps) : binary_function<SVertex *, SVertex *, bool>()
+  less_SVertex2D(real eps)
   {
     epsilon = eps;
   }
@@ -2303,10 +2303,10 @@ struct less_SVertex2D : public binary_function<SVertex *, SVertex *, bool> {
 typedef Segment<FEdge *, Vec3r> segment;
 typedef Intersection<segment> intersection;
 
-struct less_Intersection : public binary_function<intersection *, intersection *, bool> {
+struct less_Intersection {
   segment *edge;
 
-  less_Intersection(segment *iEdge) : binary_function<intersection *, intersection *, bool>()
+  less_Intersection(segment *iEdge)
   {
     edge = iEdge;
   }



More information about the Bf-blender-cvs mailing list