-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrvg-i-cubic-parameters.h
75 lines (58 loc) · 1.75 KB
/
rvg-i-cubic-parameters.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Stroke-to-fill conversion program and test harness
// Copyright (C) 2020 Diego Nehab
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// Contact information: diego.nehab@gmail.com
//
#ifndef RVG_I_CUBIC_PARAMETERS_H
#define RVG_I_CUBIC_PARAMETERS_H
#include "rvg-meta.h"
#include "rvg-floatint.h"
namespace rvg {
template <typename DERIVED>
class i_cubic_parameters {
DERIVED &derived(void) {
return *static_cast<DERIVED *>(this);
}
const DERIVED &derived(void) const {
return *static_cast<const DERIVED *>(this);
}
public:
void inflection_parameter(rvgf t) {
return derived().do_inflection_parameter(t);
}
void double_point_parameter(rvgf t) {
return derived().do_double_point_parameter(t);
}
};
}
namespace rvg {
namespace meta {
template <typename DERIVED>
using is_an_i_cubic_parameters = std::integral_constant<
bool,
is_template_base_of<
rvg::i_cubic_parameters,
typename remove_reference_cv<DERIVED>::type
>::value>;
namespace detail {
class not_an_i_cubic_parameters { };
}
template <typename U, typename T>
using inherit_if_i_cubic_parameters =
typename std::conditional<
is_an_i_cubic_parameters<U>::value,
T,
detail::not_an_i_cubic_parameters
>::type;
} } // namespace rvg::meta
#endif