Skip to content

Commit

Permalink
Fixing compilation with field marked having FixedValue.
Browse files Browse the repository at this point in the history
  • Loading branch information
arobenko committed Dec 8, 2024
1 parent f000117 commit 55711c3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
21 changes: 20 additions & 1 deletion lib/include/cc_tools_qt/details/ToolsIntFieldImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,14 @@ class ToolsIntFieldImpl : public ToolsNumericFieldImpl<cc_tools_qt::field::Tools

virtual void setDisplayValueImpl(UnderlyingType value) override
{
Base::field().setDisplayValue(value);
using Tag =
std::conditional_t<
Field::hasFixedValue(),
NoFeatureTag,
HasFeatureTag
>;

setDisplayValueInternal(value, Tag());
}

private:
Expand Down Expand Up @@ -208,7 +215,19 @@ class ToolsIntFieldImpl : public ToolsNumericFieldImpl<cc_tools_qt::field::Tools
[[maybe_unused]] static constexpr bool Must_not_be_called = false;
assert(Must_not_be_called);
return 0.0;
}

void setDisplayValueInternal(UnderlyingType value, HasFeatureTag)
{
Base::field().setDisplayValue(value);
}

void setDisplayValueInternal([[maybe_unused]] UnderlyingType value, NoFeatureTag)
{
[[maybe_unused]] static constexpr bool Must_not_be_called = false;
assert(Must_not_be_called);
}

};

template <typename TField>
Expand Down
20 changes: 19 additions & 1 deletion lib/include/cc_tools_qt/details/ToolsUnsignedLongFieldImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,14 @@ class ToolsUnsignedLongFieldImpl : public ToolsNumericFieldImpl<cc_tools_qt::fie

virtual void setDisplayValueImpl(UnderlyingType value) override
{
Base::field().setDisplayValue(value);
using Tag =
std::conditional_t<
Field::hasFixedValue(),
NoFeatureTag,
HasFeatureTag
>;

setDisplayValueInternal(value, Tag());
}

private:
Expand Down Expand Up @@ -172,6 +179,17 @@ class ToolsUnsignedLongFieldImpl : public ToolsNumericFieldImpl<cc_tools_qt::fie

return result;
}

void setDisplayValueInternal(UnderlyingType value, HasFeatureTag)
{
Base::field().setDisplayValue(value);
}

void setDisplayValueInternal([[maybe_unused]] UnderlyingType value, NoFeatureTag)
{
[[maybe_unused]] static constexpr bool Must_not_be_called = false;
assert(Must_not_be_called);
}
};

template <typename TField>
Expand Down

0 comments on commit 55711c3

Please sign in to comment.