Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using c++17 standard library #7526

Merged
merged 53 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
71b4e4f
boost::shared_ptr => std::shared_ptr
sloriot Apr 28, 2023
604dcdc
boost::optional => std::optional
sloriot Apr 28, 2023
557b64e
boost::any ==> std::any
sloriot Apr 28, 2023
9a0bdb5
boost::variant ---> std::variant
sloriot Apr 28, 2023
56499e0
do not use API that did not go into the standard
sloriot May 3, 2023
edc317d
variant::which() => variant::index() + typos
sloriot May 4, 2023
bbc48b2
more fixes
sloriot May 4, 2023
9cdfe70
Merge remote-tracking branch 'sloriot/CGAL-toward_6.0'
sloriot Jun 15, 2023
bdfa15c
fixes after merge
sloriot Jun 13, 2023
640c98f
add utility to avoid duplicate in variant + use it in SMDS_3
sloriot Jun 14, 2023
cb840ac
boost::optional::get -> std::optional::value
sloriot Jun 14, 2023
f240a47
boost::get -> std::get_if
sloriot Jun 14, 2023
76f16d7
use std::get_if, get()->value() and remove CGAL::Object usage in Env…
sloriot Jun 16, 2023
fb2f2c6
remove Object from Minkowski_sum_2
sloriot Jun 20, 2023
9969210
make is compatible with back inserter
sloriot Jun 21, 2023
7d0dd10
fix for variant/optional<variant>
sloriot Jun 21, 2023
f65aa68
use dispatch_or_drop_output to replace Object
sloriot Jun 21, 2023
11a5bfc
fix warnings
sloriot Jun 29, 2023
84abdc7
add partial specialization of Output_rep for optional and variant
sloriot Jun 29, 2023
62f22e9
use oformat for optional
sloriot Jun 29, 2023
209549d
use value instead of get_ptr
sloriot Jun 29, 2023
39878ed
fix typos
sloriot Jun 29, 2023
9526dc8
use oformat
sloriot Jun 29, 2023
f8323e7
use std API
sloriot Jun 29, 2023
65680a4
more oformat use
sloriot Jun 29, 2023
e759fb4
remove usage of old Object API
sloriot Jun 29, 2023
d91d010
add missing includes
sloriot Jun 29, 2023
f31d41c
missing include
sloriot Jun 29, 2023
9e22fdf
iformat for optional
sloriot Jun 29, 2023
a32483d
use iformat
sloriot Jun 29, 2023
b146564
fix variant output
sloriot Jun 29, 2023
b66afab
Merge remote-tracking branch 'sloriot/CGAL-using_c++17_stl' into HEAD
sloriot Jul 5, 2023
cc41b54
remove extra comment begin
sloriot Jul 12, 2023
5db2fd0
fix CK3 demo
sloriot Aug 4, 2023
7f63916
update CK2 demo
sloriot Aug 4, 2023
0ecba6b
const& should not be in the get
sloriot Aug 4, 2023
69202af
fix L1_VD demo
sloriot Aug 4, 2023
5d87958
fix format
sloriot Aug 4, 2023
f06d9fb
fix shortcut mistake
sloriot Aug 4, 2023
89fd91e
fix argt demo
sloriot Aug 4, 2023
3cef94d
make the output iterator movable
sloriot Aug 4, 2023
61874d1
do not use deprecated code
sloriot Aug 9, 2023
6b24eed
try resolving ambiguity
sloriot Aug 9, 2023
10c1796
fix unused variable warnings
sloriot Aug 9, 2023
b7cebad
do not use deprecated API
sloriot Aug 9, 2023
99066b4
hide unused type
sloriot Aug 9, 2023
71347f2
remove unused variable
sloriot Aug 9, 2023
2549f47
fix other warnings
sloriot Aug 10, 2023
5db2436
try working around an error with MSVC2017
sloriot Aug 14, 2023
eada3ee
Merge branch 'master' into 'sloriot/CGAL-using_c++17_stl'
sloriot Aug 14, 2023
d8a6478
remove another use of deprecated API
sloriot Aug 16, 2023
f1f6126
add missing IO namespace
sloriot Aug 16, 2023
d6c04e3
do not use ref wrapper
sloriot Aug 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion AABB_tree/doc/AABB_tree/Concepts/AABBGeomTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Provides the operator:
`return_type operator()(const Query& q, const Primitive::Datum& d)`,

which computes the intersection between `q` and `d`. The type of the returned object
must be a `boost::optional` of a `boost::variant` of the possible intersection types.
must be a `std::optional` of a `std::variant` of the possible intersection types.
*/
typedef unspecified_type Intersect_3;

Expand Down
6 changes: 3 additions & 3 deletions AABB_tree/doc/AABB_tree/Concepts/AABBRayIntersectionTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ class AABBRayIntersectionTraits {
/*!
A functor object to compute the distance between the source of a ray and its
closest intersection point between the ray and a primitive or a bounding box.
An empty `boost::optional` is returned, if there is no intersection.
An empty `std::optional` is returned, if there is no intersection.
When there is an intersection, an object of type `FT` is returned such that
if `i1` and `i2` are two intersection points, then `i1` is closer to the source
of the ray than `i2` iff `n1 < n2`, `n1` and `n2` being the numbers returned for `i1` and `i2`
respectively.

Provides the operators:
`boost::optional<FT> operator()(const Ray_3& r, const Bounding_box& bbox)`.
`boost::optional<std::pair<FT, Intersection_and_primitive_id<Ray_3>::%Type > >
`std::optional<FT> operator()(const Ray_3& r, const Bounding_box& bbox)`.
`std::optional<std::pair<FT, Intersection_and_primitive_id<Ray_3>::%Type > >
operator()(const Ray_3& r, const Primitive& primitive)`.

A common algorithm to compute the intersection between a bounding box and a ray is <A
Expand Down
4 changes: 2 additions & 2 deletions AABB_tree/doc/AABB_tree/Concepts/AABBTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ typedef unspecified_type Do_intersect;

/*!
A functor object to compute the intersection of a query and a primitive. Provides the operator:
`boost::optional<Intersection_and_primitive_id<Query>::%Type > operator()(const Query & q, const Primitive& primitive);` which returns the intersection as a pair composed of an object and a primitive id, iff the query intersects the primitive.
`std::optional<Intersection_and_primitive_id<Query>::%Type > operator()(const Query & q, const Primitive& primitive);` which returns the intersection as a pair composed of an object and a primitive id, iff the query intersects the primitive.

\cgalHeading{Note on Backward Compatibility}
Before the release 4.3 of \cgal, the return type of this function used to be `boost::optional<Object_and_primitive_id>`.
Before the release 4.3 of \cgal, the return type of this function used to be `std::optional<Object_and_primitive_id>`.
*/
typedef unspecified_type Intersection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef boost::optional< Tree::Intersection_and_primitive_id<Segment>::Type > Segment_intersection;
typedef boost::optional< Tree::Intersection_and_primitive_id<Plane>::Type > Plane_intersection;
typedef std::optional< Tree::Intersection_and_primitive_id<Segment>::Type > Segment_intersection;
typedef std::optional< Tree::Intersection_and_primitive_id<Plane>::Type > Plane_intersection;
typedef Tree::Primitive_id Primitive_id;

int main()
Expand Down Expand Up @@ -57,7 +57,7 @@ int main()
if(intersection)
{
// gets intersection object
const Point* p = boost::get<Point>(&(intersection->first));
const Point* p = std::get_if<Point>(&(intersection->first));
if(p)
std::cout << "intersection object is a point " << *p << std::endl;

Expand All @@ -81,7 +81,7 @@ int main()
if(plane_intersection)
{

if(boost::get<Segment>(&(plane_intersection->first)))
if(std::get_if<Segment>(&(plane_intersection->first)))
std::cout << "intersection object is a segment" << std::endl;
}

Expand Down
6 changes: 3 additions & 3 deletions AABB_tree/examples/AABB_tree/AABB_ray_shooting_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ typedef boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
typedef CGAL::AABB_face_graph_triangle_primitive<Mesh> Primitive;
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef boost::optional<Tree::Intersection_and_primitive_id<Ray>::Type> Ray_intersection;
typedef std::optional<Tree::Intersection_and_primitive_id<Ray>::Type> Ray_intersection;

struct Skip
{
Expand Down Expand Up @@ -70,8 +70,8 @@ int main(int argc, char* argv[])
Ray_intersection intersection = tree.first_intersection(ray, skip);
if(intersection)
{
if(boost::get<Point>(&(intersection->first))){
const Point* p = boost::get<Point>(&(intersection->first) );
if(std::get_if<Point>(&(intersection->first))){
const Point* p = std::get_if<Point>(&(intersection->first) );
std::cout << *p << std::endl;
}
}
Expand Down
18 changes: 9 additions & 9 deletions AABB_tree/include/CGAL/AABB_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <CGAL/Kernel_23/internal/Has_boolean_tags.h>


#include <boost/optional.hpp>
#include <optional>

/// \file AABB_traits.h

Expand All @@ -39,7 +39,7 @@ template <class T>
struct Remove_optional { typedef T type; };

template <class T>
struct Remove_optional< ::boost::optional<T> > { typedef T type; };
struct Remove_optional< ::std::optional<T> > { typedef T type; };

//helper controlling whether extra data should be stored in the AABB_tree traits class
template <class Primitive, bool has_shared_data=Has_nested_type_Shared_data<Primitive>::value>
Expand Down Expand Up @@ -85,7 +85,7 @@ struct AABB_traits_base_2<GeomTraits,true>{
typedef typename CGAL::Bbox_3 Bounding_box;

struct Intersection_distance {
boost::optional<FT> operator()(const Ray_3& ray, const Bounding_box& bbox) const {
std::optional<FT> operator()(const Ray_3& ray, const Bounding_box& bbox) const {
FT t_near = -DBL_MAX; // std::numeric_limits<FT>::lowest(); C++1903
FT t_far = DBL_MAX;

Expand All @@ -101,7 +101,7 @@ struct AABB_traits_base_2<GeomTraits,true>{
for(int i = 0; i < 3; ++i, ++source_iter, ++direction_iter) {
if(*direction_iter == 0) {
if((*source_iter < (bbox.min)(i)) || (*source_iter > (bbox.max)(i))) {
return boost::none;
return std::nullopt;
}
} else {
FT t1 = ((bbox.min)(i) - *source_iter) / *direction_iter;
Expand All @@ -118,7 +118,7 @@ struct AABB_traits_base_2<GeomTraits,true>{
// t_far = t2;

if(t_near > t_far || t_far < FT(0.))
return boost::none;
return std::nullopt;
}
}

Expand Down Expand Up @@ -193,7 +193,7 @@ class AABB_traits

/// `Intersection_and_primitive_id<Query>::%Type::first_type` is found according to
/// the result type of `GeomTraits::Intersect_3::operator()`. If it is
/// `boost::optional<T>` then it is `T`, and the result type otherwise.
/// `std::optional<T>` then it is `T`, and the result type otherwise.
template<typename Query>
struct Intersection_and_primitive_id {
typedef decltype(
Expand Down Expand Up @@ -364,12 +364,12 @@ class AABB_traits
Intersection(const AABB_traits<GeomTraits,AABBPrimitive,BboxMap>& traits)
:m_traits(traits) {}
template<typename Query>
boost::optional< typename Intersection_and_primitive_id<Query>::Type >
std::optional< typename Intersection_and_primitive_id<Query>::Type >
operator()(const Query& query, const typename AT::Primitive& primitive) const {
auto inter_res = GeomTraits().intersect_3_object()(query, internal::Primitive_helper<AT>::get_datum(primitive,m_traits));
if (!inter_res)
return boost::none;
return boost::make_optional( std::make_pair(*inter_res, primitive.id()) );
return std::nullopt;
return std::make_optional( std::make_pair(*inter_res, primitive.id()) );
}
};

Expand Down
18 changes: 9 additions & 9 deletions AABB_tree/include/CGAL/AABB_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <CGAL/AABB_tree/internal/AABB_search_tree.h>
#include <CGAL/AABB_tree/internal/Has_nested_type_Shared_data.h>
#include <CGAL/AABB_tree/internal/Primitive_helper.h>
#include <boost/optional.hpp>
#include <optional>
#include <boost/lambda/lambda.hpp>

#ifdef CGAL_HAS_THREADS
Expand Down Expand Up @@ -271,7 +271,7 @@ namespace CGAL {
/// \tparam Query must be a type for which `Do_intersect` operators are
/// defined in the traits class `AABBTraits`.
template <typename Query>
boost::optional<Primitive_id> any_intersected_primitive(const Query& query) const;
std::optional<Primitive_id> any_intersected_primitive(const Query& query) const;
///@}

/// \name Intersections
Expand All @@ -294,7 +294,7 @@ namespace CGAL {
/// \tparam Query must be a type for which `Do_intersect` and `Intersection` operators are
/// defined in the traits class `AABBTraits`.
template <typename Query>
boost::optional< typename Intersection_and_primitive_id<Query>::Type >
std::optional< typename Intersection_and_primitive_id<Query>::Type >
any_intersection(const Query& query) const;


Expand All @@ -318,12 +318,12 @@ namespace CGAL {
/// `AABBTraits` must be a model of `AABBRayIntersectionTraits` to
/// call this member function.
template<typename Ray, typename SkipFunctor>
boost::optional< typename Intersection_and_primitive_id<Ray>::Type >
std::optional< typename Intersection_and_primitive_id<Ray>::Type >
first_intersection(const Ray& query, const SkipFunctor& skip) const;

/// \cond
template<typename Ray>
boost::optional< typename Intersection_and_primitive_id<Ray>::Type >
std::optional< typename Intersection_and_primitive_id<Ray>::Type >
first_intersection(const Ray& query) const
{
return first_intersection(query, boost::lambda::constant(false));
Expand All @@ -343,12 +343,12 @@ namespace CGAL {
/// `AABBTraits` must be a model of `AABBRayIntersectionTraits` to
/// call this member function.
template<typename Ray, typename SkipFunctor>
boost::optional<Primitive_id>
std::optional<Primitive_id>
first_intersected_primitive(const Ray& query, const SkipFunctor& skip) const;

/// \cond
template<typename Ray>
boost::optional<Primitive_id>
std::optional<Primitive_id>
first_intersected_primitive(const Ray& query) const
{
return first_intersected_primitive(query, boost::lambda::constant(false));
Expand Down Expand Up @@ -964,7 +964,7 @@ namespace CGAL {

template <typename Tr>
template <typename Query>
boost::optional< typename AABB_tree<Tr>::template Intersection_and_primitive_id<Query>::Type >
std::optional< typename AABB_tree<Tr>::template Intersection_and_primitive_id<Query>::Type >
AABB_tree<Tr>::any_intersection(const Query& query) const
{
using namespace CGAL::internal::AABB_tree;
Expand All @@ -976,7 +976,7 @@ namespace CGAL {

template <typename Tr>
template <typename Query>
boost::optional<typename AABB_tree<Tr>::Primitive_id>
std::optional<typename AABB_tree<Tr>::Primitive_id>
AABB_tree<Tr>::any_intersected_primitive(const Query& query) const
{
using namespace CGAL::internal::AABB_tree;
Expand Down
29 changes: 14 additions & 15 deletions AABB_tree/include/CGAL/AABB_tree/internal/AABB_ray_intersection.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

#include <functional>
#include <type_traits>
#include <boost/optional.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <optional>
# if defined(BOOST_MSVC)
# pragma warning(push)
# pragma warning(disable: 4996)
Expand All @@ -43,7 +42,7 @@ class AABB_ray_intersection {
public:
AABB_ray_intersection(const AABBTree& tree) : tree_(tree) {}

boost::optional< Ray_intersection_and_primitive_id >
std::optional< Ray_intersection_and_primitive_id >
ray_intersection(const Ray& query, SkipFunctor skip) const {
// We hit the root, now continue on the children. Keep track of
// nb_primitives through a variable in each Node on the stack. In
Expand All @@ -63,7 +62,7 @@ class AABB_ray_intersection {

Heap_type pq;
// pq.reserve(tree_.size() / 2);
boost::optional< Ray_intersection_and_primitive_id >
std::optional< Ray_intersection_and_primitive_id >
intersection, /* the temporary for calculating the result */
p; /* the current best intersection */

Expand All @@ -84,7 +83,7 @@ class AABB_ray_intersection {
if(!skip(current.node->left_data().id()) /* && do_intersect_obj(query, current.node->left_data()) */) {
intersection = intersection_obj(query, current.node->left_data());
if(intersection) {
FT ray_distance = boost::apply_visitor(param_visitor, intersection->first);
FT ray_distance = std::visit(param_visitor, intersection->first);
if(ray_distance < t) {
t = ray_distance;
p = intersection;
Expand All @@ -96,7 +95,7 @@ class AABB_ray_intersection {
if(!skip(current.node->right_data().id()) /* && do_intersect_obj(query, current.node->right_data()) */) {
intersection = intersection_obj(query, current.node->right_data());
if(intersection) {
FT ray_distance = boost::apply_visitor(param_visitor, intersection->first);
FT ray_distance = std::visit(param_visitor, intersection->first);
if(ray_distance < t) {
t = ray_distance;
p = intersection;
Expand All @@ -111,7 +110,7 @@ class AABB_ray_intersection {
if(!skip(current.node->left_data().id()) /* && do_intersect_obj(query, current.node->left_data()) */) {
intersection = intersection_obj(query, current.node->left_data());
if(intersection) {
FT ray_distance = boost::apply_visitor(param_visitor, intersection->first);
FT ray_distance = std::visit(param_visitor, intersection->first);
if(ray_distance < t) {
t = ray_distance;
p = intersection;
Expand All @@ -121,7 +120,7 @@ class AABB_ray_intersection {

// right child
const Node* child = &(current.node->right_child());
boost::optional< FT > dist = intersection_distance_obj(query, child->bbox());
std::optional< FT > dist = intersection_distance_obj(query, child->bbox());
if(dist)
pq.push(Node_ptr_with_ft(child, *dist, 2));

Expand All @@ -130,7 +129,7 @@ class AABB_ray_intersection {
default: // Children both inner nodes
{
const Node* child = &(current.node->left_child());
boost::optional<FT> dist = intersection_distance_obj(query, child->bbox());
std::optional<FT> dist = intersection_distance_obj(query, child->bbox());
if(dist)
pq.push(Node_ptr_with_ft(child, *dist, current.nb_primitives/2));

Expand Down Expand Up @@ -198,7 +197,7 @@ class AABB_ray_intersection {

template<typename AABBTraits>
template<typename Ray, typename SkipFunctor>
boost::optional< typename AABB_tree<AABBTraits>::template Intersection_and_primitive_id<Ray>::Type >
std::optional< typename AABB_tree<AABBTraits>::template Intersection_and_primitive_id<Ray>::Type >
AABB_tree<AABBTraits>::first_intersection(const Ray& query,
const SkipFunctor& skip) const {
static_assert((std::is_same<Ray, typename AABBTraits::Ray_3>::value),
Expand All @@ -219,22 +218,22 @@ AABB_tree<AABBTraits>::first_intersection(const Ray& query,
break;
}
}
return boost::none;
return std::nullopt;
}

template<typename AABBTraits>
template<typename Ray, typename SkipFunctor>
boost::optional<typename AABB_tree<AABBTraits>::Primitive_id>
std::optional<typename AABB_tree<AABBTraits>::Primitive_id>
AABB_tree<AABBTraits>::first_intersected_primitive(const Ray& query,
const SkipFunctor& skip) const
{
boost::optional<
std::optional<
typename AABB_tree<AABBTraits>::
template Intersection_and_primitive_id<Ray>::Type > res =
first_intersection(query, skip);
if ( (bool) res )
return boost::make_optional( res->second );
return boost::none;
return std::make_optional( res->second );
return std::nullopt;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


#include <CGAL/AABB_tree/internal/AABB_node.h>
#include <boost/optional.hpp>
#include <optional>

namespace CGAL {

Expand Down Expand Up @@ -69,7 +69,7 @@ class First_intersection_traits

public:
typedef
boost::optional< typename AABBTraits::template Intersection_and_primitive_id<Query>::Type >
std::optional< typename AABBTraits::template Intersection_and_primitive_id<Query>::Type >
Result;
public:
First_intersection_traits(const AABBTraits& traits)
Expand Down Expand Up @@ -124,7 +124,7 @@ class Listing_intersection_traits

void intersection(const Query& query, const Primitive& primitive)
{
boost::optional< typename AABBTraits::template Intersection_and_primitive_id<Query>::Type >
std::optional< typename AABBTraits::template Intersection_and_primitive_id<Query>::Type >
intersection = m_traits.intersection_object()(query, primitive);

if(intersection)
Expand Down Expand Up @@ -211,7 +211,7 @@ class First_primitive_traits
{
if( m_traits.do_intersect_object()(query, primitive) )
{
m_result = boost::optional<typename Primitive::Id>(primitive.id());
m_result = std::optional<typename Primitive::Id>(primitive.id());
m_is_found = true;
}
}
Expand All @@ -221,12 +221,12 @@ class First_primitive_traits
return m_traits.do_intersect_object()(query, node.bbox());
}

boost::optional<typename Primitive::Id> result() const { return m_result; }
std::optional<typename Primitive::Id> result() const { return m_result; }
bool is_intersection_found() const { return m_is_found; }

private:
bool m_is_found;
boost::optional<typename Primitive::Id> m_result;
std::optional<typename Primitive::Id> m_result;
const AABBTraits& m_traits;
};

Expand Down
Loading