boostorg / boostorg/gil

Add arithmetic operators for float and double grayscale pixels

Open
#615 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
199
Forks
171
Avg merge
1d 14h
Merged PRs (30d)
10

Description

### Is your feature request related to a problem? Please describe.

I was surprised to see that arithmetic operations on `pixel` compiles but without explicit support from the library. `pixel`s are actually implicitly converted to their underlying type.

### Describe the solution you'd like

Provide a set of arithmetic operators, at least for `pixel_gray32f_t` and `pixel_gray64f_t`.

#### C++ Example

```cpp
#include
#include
using pixel_t = boost::gil::pixel > >;
int main()
{
pixel_t a(1.0f), b(2.0f);
auto c = a + b;
static_assert(std::is_same_v, float>); //OK , but is implicit conversion right?
static_assert(std::is_same_v, pixel_t>); //Fails, but should be OK?
return 0;
}
```

### Additional context

Discussed first on [Slack](https://cpplang.slack.com/archives/CSVT0STV2/p1622797174115100)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.