Various small simplifications

This commit is contained in:
Marc Glisse 2019-02-08 16:54:08 +01:00
parent 02cfcafb72
commit f099add88e
5 changed files with 14 additions and 25 deletions

View File

@ -60,8 +60,6 @@ class Filtered_predicate2
C2E c2e;
C2A c2a;
typedef typename AP::result_type Ares;
public:
typedef AP Approximate_predicate;
@ -92,7 +90,7 @@ public:
try
{
// No forward here, the arguments may still be needed
Ares res = ap(c2a(args)...);
auto res = ap(c2a(args)...);
if (is_certain(res))
return get_certain(res);
}

View File

@ -49,15 +49,15 @@ template <int d, class K1, class K2>
struct Point_converter_help<Dimension_tag<d>,K1,K2> {
typedef typename Get_type<K1, Point_tag>::type argument_type;
typedef typename Get_type<K2, Point_tag>::type result_type;
template <class C,int...I>
result_type help(Indices<I...>, K1 const& k1, K2 const& k2, C const& conv, argument_type const& p) const {
template <class C,std::size_t...I>
result_type help(std::index_sequence<I...>, K1 const& k1, K2 const& k2, C const& conv, argument_type const& p) const {
typename Get_functor<K1, Compute_point_cartesian_coordinate_tag>::type cc(k1);
typename Get_functor<K2, Construct_ttag<Point_tag> >::type cp(k2);
return cp(conv(cc(p,I))...);
}
template <class C>
result_type operator()(K1 const& k1, K2 const& k2, C const& conv, argument_type const& p) const {
return help(typename N_increasing_indices<d>::type(),k1,k2,conv,p);
return help(std::make_index_sequence<d>(),k1,k2,conv,p);
}
};
}

View File

@ -85,8 +85,8 @@ template<class R_> struct Construct_segment : Store_kernel<R_> {
result_type operator()(T&&, U&& u, V&& v)const{
CP cp(this->kernel());
result_type r = {{
call_on_tuple_elements<Point>(cp, std::forward<U>(u)),
call_on_tuple_elements<Point>(cp, std::forward<V>(v)) }};
call_on_tuple_elements(cp, std::forward<U>(u)),
call_on_tuple_elements(cp, std::forward<V>(v)) }};
return r;
}
};

View File

@ -91,7 +91,7 @@ template<class R_,int d> struct Orientation_of_points<R_,Dimension_tag<d>,true>
typedef typename Get_type<R, Point_tag>::type Point;
typedef typename Get_type<R, Orientation_tag>::type result_type;
template<class>struct Help;
template<int...I>struct Help<Indices<I...> > {
template<std::size_t...I>struct Help<std::index_sequence<I...> > {
template<class C,class P,class T> result_type operator()(C const&c,P const&x,T&&t)const{
return sign_of_determinant<RT>(c(std::get<I/d>(t),I%d)-c(x,I%d)...);
}
@ -99,7 +99,7 @@ template<class R_,int d> struct Orientation_of_points<R_,Dimension_tag<d>,true>
template<class P0,class...P> result_type operator()(P0 const&x,P&&...p)const{
static_assert(d==sizeof...(P),"Wrong number of arguments");
typename Get_functor<R, Compute_point_cartesian_coordinate_tag>::type c(this->kernel());
return Help<typename N_increasing_indices<d*d>::type>()(c,x,std::forward_as_tuple(std::forward<P>(p)...));
return Help<std::make_index_sequence<d*d>>()(c,x,std::forward_as_tuple(std::forward<P>(p)...));
}

View File

@ -149,32 +149,23 @@ struct Has_type_different_from <T, No, true>
template<class It> struct result<Dereference_functor(It)> {
typedef typename std::iterator_traits<It>::reference type;
};
template<class It> typename result<Dereference_functor(It)>::type
template<class It> decltype(auto)
operator()(It const&i)const{
return *i;
}
};
template<int...> struct Indices{};
template<class> struct Next_increasing_indices;
template<int...I> struct Next_increasing_indices<Indices<I...> > {
typedef Indices<I...,sizeof...(I)> type;
};
template<int N> struct N_increasing_indices {
typedef typename Next_increasing_indices<typename N_increasing_indices<N-1>::type>::type type;
};
template<> struct N_increasing_indices<0> { typedef Indices<> type; };
namespace internal {
template<class F,class...U,int...I> inline typename std::result_of<F&&(U...)>::type
do_call_on_tuple_elements(F&&f, std::tuple<U...>&&t, Indices<I...>&&) {
template<class F,class...U,std::size_t...I> inline decltype(auto)
do_call_on_tuple_elements(F&&f, std::tuple<U...>&&t, std::index_sequence<I...>&&) {
return f(std::get<I>(std::move(t))...);
}
} // internal
template<class/*result type, ignored*/,class F,class...U>
inline typename std::result_of<F&&(U...)>::type
template<class F,class...U>
inline decltype(auto)
call_on_tuple_elements(F&&f, std::tuple<U...>&&t) {
return internal::do_call_on_tuple_elements(std::forward<F>(f),std::move(t),
typename N_increasing_indices<sizeof...(U)>::type());
std::make_index_sequence<sizeof...(U)>());
}
template<class A> struct Factory {