eclipse-iceoryx / eclipse-iceoryx/iceoryx

Implement `minVal` and `maxVal` without references to be usable by static constexpr members

Open
#1,712 0 comments 0 reactions 0 assignees View on GitHub
refactoring
Dominant language
C++
Stars
2.2k
Forks
492
Avg merge
18h 57m
Merged PRs (30d)
1

Description

## Brief feature description

Currently even constexpr static members in C++ must be explicitly instantiated in a cpp file. With C++17 and inline constexpr this issue is fixed.
If one would like to use a constexpr static member in C++ in combination with the constexpr `algorithm::minVal/maxVal` one gets a linker error since it is not explicitly instantiated and those methods require a reference.

This could be solved by adding a `constexpr` version of minVal/maxVal which are using non - references as parameters.

See this code snippet to illustrate the problem:
```
// in some header
struct Bla {
static constexpr int SomeVal = 123;
};

// in another header we use
// constexpr T minVal(const T &a, const T &b);
cxx::vector blubb; // leads to linker error

// fix:
constexpr T minVal(const T a, const T b);
```

Contributor guide

Open the contributing guide

Research direction

Locate algorithm::minVal and maxVal and their existing tests; first inspect the reference-taking overloads and run the focused algorithm test target. Done means the constexpr static-member example compiles without a linker error and the new behavior is covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.