Skip to content

Commit

Permalink
fix clang-16 compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
schaumb committed Dec 12, 2024
1 parent cfb881f commit b6deaa0
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 12 deletions.
25 changes: 19 additions & 6 deletions src/base/math/segmentedfunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ template <typename T, class CRTP> struct SegmentedFunction
{
CRTP res;

auto &&transformer = [](auto &&another)
auto merger = [](const Stop &item1, const Stop &item2)
{
return Stop{item1.pos, item1.value + item2.value};
};

auto &&transformer = [](const CRTP &another)
{
return [&another](const Stop &item)
{
Expand All @@ -53,13 +58,21 @@ template <typename T, class CRTP> struct SegmentedFunction
Alg::merge(self.stops,
other.stops,
res.stops,
Alg::merge_args{.projection = &Stop::pos,
Alg::merge_args
// { Remove when clang-16 not used
<std::identity,
std::identity,
double Stop::*,
decltype(std::weak_order),
decltype(transformer(other)),
decltype(transformer(self)),
Alg::Merge::always,
decltype(merger)>
// }
{.projection = &Stop::pos,
.transformer_1 = transformer(other),
.transformer_2 = transformer(self),
.merger = [](const Stop &item1, const Stop &item2)
{
return Stop{item1.pos, item1.value + item2.value};
}});
.merger = merger});
return res;
}

Expand Down
35 changes: 29 additions & 6 deletions src/chart/generator/axis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ DimensionAxis interpolate(const DimensionAxis &op0,
const Val *latest1{};
const Val *latest2{};

auto &&merger = [&](const Val &lhs, const Val &rhs) -> Val
auto merger = [&](const Val &lhs, const Val &rhs) -> Val
{
latest1 = std::addressof(lhs);
latest2 = std::addressof(rhs);
Expand Down Expand Up @@ -332,7 +332,18 @@ DimensionAxis interpolate(const DimensionAxis &op0,
Alg::merge(op0.values,
op1.values,
res.values,
Alg::merge_args{.projection = &Val::first,
Alg::merge_args
// { Remove when clang-16 not used
<std::identity,
std::identity,
const Data::SliceIndex Val::*,
decltype(std::weak_order),
decltype(one_side({}, {}, latest1)),
decltype(one_side({}, {}, latest1)),
Alg::Merge::always,
decltype(merger)>
// }
{.projection = &Val::first,
.transformer_1 =
one_side(true, &DimensionAxis::Item::endPos, latest2),
.transformer_2 = one_side(false,
Expand Down Expand Up @@ -381,8 +392,9 @@ interpolate(const SplitAxis &op0, const SplitAxis &op1, double factor)
};
};

auto &&one_side = [needMerge](const decltype(merger(0.0)) &merger,
bool needOther)
using MergerType = decltype(merger(0.0));
auto &&one_side =
[needMerge](const MergerType &merger, bool needOther)
{
return
[needMerge, &merger, needOther, firstSpecial = needOther](
Expand All @@ -391,7 +403,7 @@ interpolate(const SplitAxis &op0, const SplitAxis &op1, double factor)
if (needMerge) {
if (firstSpecial) {
firstSpecial = false;
return merger(val, {});
return merger(val, PartPair{});
}

Math::Range<> range{0.0, 1.0};
Expand All @@ -412,7 +424,18 @@ interpolate(const SplitAxis &op0, const SplitAxis &op1, double factor)
Alg::merge(op0.parts,
op1.parts,
res.parts,
Alg::merge_args{.projection = &PartPair::first,
Alg::merge_args
// { Remove when clang-16 not used
<std::identity,
std::identity,
const std::optional<Data::SliceIndex> PartPair::*,
decltype(std::weak_order),
decltype(one_side(merger({}), {})),
decltype(one_side(merger({}), {})),
Alg::Merge::always,
const MergerType &>
// }
{.projection = &PartPair::first,
.transformer_1 =
one_side(merger(factor), op1.parts.size() <= 1),
.transformer_2 =
Expand Down

0 comments on commit b6deaa0

Please sign in to comment.