xo-ratio: workaround: clang reqs public structural-type members
This commit is contained in:
parent
99b429cf28
commit
d949a2de2a
1 changed files with 9 additions and 0 deletions
|
|
@ -62,6 +62,12 @@ namespace {
|
|||
}
|
||||
}
|
||||
|
||||
/* verify can use ratio instance as template argument */
|
||||
using ratio64_t = xo::ratio::ratio<int64_t>;
|
||||
|
||||
template<ratio64_t Ratio>
|
||||
constexpr double my_ratio_approx = Ratio.num_ / static_cast<double>(Ratio.den_);
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -72,6 +78,9 @@ main() {
|
|||
using xo::flatstring;
|
||||
using namespace std;
|
||||
|
||||
static_assert(my_ratio_approx<ratio64_t(1, 2)> == 0.5);
|
||||
static_assert(my_ratio_approx<ratio64_t{}> == 0.0);
|
||||
|
||||
constexpr auto r1 = make_ratio(2, 3);
|
||||
cerr << "r1=make_ratio(2,3): " << r1 << endl; // output <ratio 2/3>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue