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

Fix dangling reference in Construct_center_3(Circle_3) #8586

Open
wants to merge 7 commits into
base: 5.6.x-branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cartesian_kernel/include/CGAL/Cartesian/Circle_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ class CircleC3 {
return diametral_sphere();
}

Point_3 center() const
decltype(auto) center() const
{
return diametral_sphere().center();
}

FT squared_radius() const
decltype(auto) squared_radius() const
{
return diametral_sphere().squared_radius();
}
Expand All @@ -155,7 +155,7 @@ class CircleC3 {
return CGAL_PI * CGAL_PI * 4.0 * to_double(squared_radius());
}

FT area_divided_by_pi() const
decltype(auto) area_divided_by_pi() const
{
return squared_radius();
}
Expand Down
35 changes: 13 additions & 22 deletions Cartesian_kernel/include/CGAL/Cartesian/function_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -1053,13 +1053,9 @@ namespace CartesianKernelFunctors {
class Compute_area_divided_by_pi_3
{
typedef typename K::Circle_3 Circle_3;
typedef typename K::FT FT;

public:

typedef FT result_type;

result_type
decltype(auto) // FT or const FT&
operator()(const Circle_3 & c) const
{ return c.rep().area_divided_by_pi(); }

Expand Down Expand Up @@ -1189,31 +1185,27 @@ namespace CartesianKernelFunctors {
typedef typename K::FT FT;
typedef typename K::Point_2 Point_2;
typedef typename K::Circle_2 Circle_2;
public:
typedef FT result_type;

result_type
public:
decltype(auto)
operator()( const Circle_2& c) const
{ return c.rep().squared_radius(); }

result_type
FT
operator()( const Point_2& /*p*/) const
{ return FT(0); }

result_type
FT
operator()( const Point_2& p, const Point_2& q) const
{ return squared_radiusC2(p.x(), p.y(), q.x(), q.y()); }

result_type
FT
operator()( const Point_2& p, const Point_2& q, const Point_2& r) const
{ return squared_radiusC2(p.x(), p.y(), q.x(), q.y(), r.x(), r.y()); }
};

} //namespace CartesianKernelFunctors

// For the non specialized template will do the right thing,
// namely return a copy of an FT

namespace CartesianKernelFunctors {

template <typename K>
Expand All @@ -1223,22 +1215,21 @@ namespace CartesianKernelFunctors {
typedef typename K::Point_3 Point_3;
typedef typename K::Sphere_3 Sphere_3;
typedef typename K::Circle_3 Circle_3;
public:
typedef FT result_type;

result_type
public:
decltype(auto)
operator()( const Sphere_3& s) const
{ return s.rep().squared_radius(); }

result_type
decltype(auto)
operator()( const Circle_3& c) const
{ return c.rep().squared_radius(); }

result_type
FT
operator()( const Point_3& /*p*/) const
{ return FT(0); }

result_type
FT
operator()( const Point_3& p, const Point_3& q) const
{
FT num, den;
Expand All @@ -1248,7 +1239,7 @@ namespace CartesianKernelFunctors {
return num / den;
}

result_type
FT
operator()( const Point_3& p, const Point_3& q, const Point_3& r) const
{
FT num, den;
Expand All @@ -1259,7 +1250,7 @@ namespace CartesianKernelFunctors {
return num / den;
}

result_type
FT
operator()( const Point_3& p, const Point_3& q,
const Point_3& r, const Point_3& s) const
{
Expand Down
10 changes: 5 additions & 5 deletions Kernel_23/include/CGAL/Circle_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ template <class R_>
return typename R::Construct_sphere_3()(*this);
}

Point_3 center() const
decltype(auto) center() const
{
return typename R::Construct_sphere_3()(*this).center();
return diametral_sphere().center();
}

FT squared_radius() const
decltype(auto) squared_radius() const
{
return typename R::Construct_sphere_3()(*this).squared_radius();
return diametral_sphere().squared_radius();
}

decltype(auto)
Expand All @@ -122,7 +122,7 @@ template <class R_>
return typename R::Construct_bbox_3()(*this);
}

FT area_divided_by_pi() const
decltype(auto) area_divided_by_pi() const
{
return typename R::Compute_area_divided_by_pi_3()(*this);
}
Expand Down
44 changes: 12 additions & 32 deletions Kernel_23/include/CGAL/Kernel/function_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -1120,8 +1120,6 @@ namespace CommonKernelFunctors {
typedef typename K::Line_2 Line_2;

public:
typedef RT result_type;

const RT&
operator()(const Line_2& l) const
{
Expand All @@ -1136,8 +1134,6 @@ namespace CommonKernelFunctors {
typedef typename K::Plane_3 Plane_3;

public:
typedef RT result_type;

const RT&
operator()(const Plane_3& l) const
{
Expand All @@ -1153,8 +1149,6 @@ namespace CommonKernelFunctors {
typedef typename K::Line_2 Line_2;

public:
typedef RT result_type;

const RT&
operator()(const Line_2& l) const
{
Expand All @@ -1169,8 +1163,6 @@ namespace CommonKernelFunctors {
typedef typename K::Plane_3 Plane_3;

public:
typedef RT result_type;

const RT&
operator()(const Plane_3& l) const
{
Expand All @@ -1186,8 +1178,6 @@ namespace CommonKernelFunctors {
typedef typename K::Line_2 Line_2;

public:
typedef RT result_type;

const RT&
operator()(const Line_2& l) const
{
Expand All @@ -1202,8 +1192,6 @@ namespace CommonKernelFunctors {
typedef typename K::Plane_3 Plane_3;

public:
typedef RT result_type;

const RT&
operator()(const Plane_3& l) const
{
Expand All @@ -1218,8 +1206,6 @@ namespace CommonKernelFunctors {
typedef typename K::Plane_3 Plane_3;

public:
typedef RT result_type;

const RT&
operator()(const Plane_3& l) const
{
Expand Down Expand Up @@ -1486,10 +1472,9 @@ namespace CommonKernelFunctors {
{
typedef typename K::Point_2 Point_2;
typedef typename K::Circle_2 Circle_2;
public:
typedef const Point_2& result_type;

result_type
public:
decltype(auto)
operator()(const Circle_2& c) const
{ return c.rep().center(); }
};
Expand All @@ -1500,14 +1485,13 @@ namespace CommonKernelFunctors {
typedef typename K::Point_3 Point_3;
typedef typename K::Sphere_3 Sphere_3;
typedef typename K::Circle_3 Circle_3;
public:
typedef const Point_3& result_type;

result_type
public:
decltype(auto)
operator()(const Sphere_3& s) const
{ return s.rep().center(); }

result_type
decltype(auto)
operator()(const Circle_3& c) const
{ return c.rep().center(); }

Expand Down Expand Up @@ -2108,9 +2092,8 @@ namespace CommonKernelFunctors {
typedef typename K::Plane_3 Plane_3;
typedef typename K::Circle_3 Circle_3;
typedef typename Plane_3::Rep Rep;
public:
typedef Plane_3 result_type;

public:
Rep // Plane_3
operator()(Return_base_tag, const RT& a, const RT& b, const RT& c, const RT& d) const
{ return Rep(a, b, c, d); }
Expand Down Expand Up @@ -2147,7 +2130,7 @@ namespace CommonKernelFunctors {
operator()(Return_base_tag, const Segment_3& s, const Point_3& p) const
{ return Rep(s, p); }

Rep // Plane_3
decltype(auto)
operator()(Return_base_tag, const Circle_3 & c) const
{ return c.rep().supporting_plane(); }

Expand Down Expand Up @@ -2179,7 +2162,7 @@ namespace CommonKernelFunctors {
operator()(const Segment_3& s, const Point_3& p) const
{ return this->operator()(Return_base_tag(), s, p); }

Plane_3
decltype(auto)
operator()(const Circle_3 & c) const
{ return this->operator()(Return_base_tag(), c); }

Expand Down Expand Up @@ -2257,9 +2240,8 @@ namespace CommonKernelFunctors {
typedef typename K::Line_3 Line_3;
typedef typename K::Ray_3 Ray_3;
typedef typename K::Plane_3 Plane_3;
public:
typedef Point_3 result_type;

public:
const Point_3&
operator()( const Line_3& l) const
{ return l.rep().point(); }
Expand Down Expand Up @@ -2523,9 +2505,8 @@ namespace CommonKernelFunctors {
typedef typename K::Sphere_3 Sphere_3;
typedef typename K::Circle_3 Circle_3;
typedef typename Sphere_3::Rep Rep;
public:
typedef Sphere_3 result_type;

public:
Rep // Sphere_3
operator()(Return_base_tag, const Point_3& center, const FT& squared_radius,
Orientation orientation = COUNTERCLOCKWISE) const
Expand All @@ -2551,7 +2532,7 @@ namespace CommonKernelFunctors {
Orientation orientation = COUNTERCLOCKWISE) const
{ return Rep(center, orientation); }

Rep
decltype(auto)
operator() (Return_base_tag, const Circle_3 & c) const
{ return c.rep().diametral_sphere(); }

Expand Down Expand Up @@ -2580,10 +2561,9 @@ namespace CommonKernelFunctors {
Orientation orientation = COUNTERCLOCKWISE) const
{ return this->operator()(Return_base_tag(), center, orientation); }

Sphere_3
decltype(auto)
operator() (const Circle_3 & c) const
{ return this->operator()(Return_base_tag(), c); }

};

template <typename K>
Expand Down
2 changes: 1 addition & 1 deletion Kernel_23/include/CGAL/Sphere_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Sphere_3 : public R_::Kernel_base::Sphere_3
return R().construct_center_3_object()(*this);
}

FT
decltype(auto)
squared_radius() const
{
return R().compute_squared_radius_3_object()(*this);
Expand Down
Loading
Loading