example of perfect forwarding for Point_3

This commit is contained in:
Sébastien Loriot 2023-04-06 17:25:17 +02:00 committed by Andreas Fabri
parent 1d5f57ebb7
commit 8a5fc31c6c
4 changed files with 25 additions and 2 deletions

View File

@ -45,6 +45,11 @@ public:
PointC3(const FT &x, const FT &y, const FT &z)
: base(x, y, z) {}
PointC3(FT &&x, FT &&y, FT &&z)
: base(std::forward<FT>(x), std::forward<FT>(y), std::forward<FT>(z))
{}
PointC3(const FT &x, const FT &y, const FT &z, const FT &w)
: base(x, y, z, w) {}

View File

@ -65,7 +65,10 @@ public:
{ *this = R().construct_vector_3_object()(l); }
VectorC3(const FT_ &x, const FT_ &y, const FT_ &z)
: base(CGAL::make_array(x, y, z)) {}
: base(Rep{x, y, z}) {}
VectorC3(FT_ &&x, FT_ &&y, FT_ &&z)
: base(Rep{x, y, z}) {}
VectorC3(const FT_ &x, const FT_ &y, const FT_ &z, const FT_ &w)
: base( w != FT_(1) ? CGAL::make_array<FT_>(x/w, y/w, z/w)

View File

@ -3160,6 +3160,10 @@ namespace CartesianKernelFunctors {
operator()(Return_base_tag, const RT& x, const RT& y, const RT& z) const
{ return Rep(x, y, z); }
Rep // Point_3
operator()(Return_base_tag, RT&& x, RT&& y, RT&& z) const
{ return Rep(std::forward<RT>(x), std::forward<RT>(y), std::forward<RT>(z)); }
Rep // Point_3
operator()(Return_base_tag, const RT& x, const RT& y, const RT& z, const RT& w) const
{ return Rep(x, y, z, w); }
@ -3180,6 +3184,10 @@ namespace CartesianKernelFunctors {
operator()(const RT& x, const RT& y, const RT& z) const
{ return Point_3(x, y, z); }
Point_3
operator()(RT&& x, RT&& y, RT&& z) const
{ return Point_3(std::forward<RT>(x), std::forward<RT>(y), std::forward<RT>(z)); }
Point_3
operator()(const RT& x, const RT& y, const RT& z, const RT& w) const
{ return Point_3(x, y, z, w); }

View File

@ -79,6 +79,13 @@ public:
: Rep(typename R::Construct_point_3()(Return_base_tag(), x, y, z))
{}
template < typename T1, typename T2, typename T3 >
Point_3(T1&& x, T2&& y, T3&& z)
: Rep(typename R::Construct_point_3()(Return_base_tag(), std::forward<T1>(x),
std::forward<T2>(y),
std::forward<T3>(z)))
{}
Point_3(const RT& hx, const RT& hy, const RT& hz, const RT& hw)
: Rep(typename R::Construct_point_3()(Return_base_tag(), hx, hy, hz, hw))
{}
@ -283,7 +290,7 @@ extract(std::istream& is, Point_3<R>& p, const Cartesian_tag&)
break;
}
if (is)
p = Point_3<R>(x, y, z);
p = Point_3<R>(std::move(x), std::move(y), std::move(z));
return is;
}