Skip to content

Commit b0327c2

Browse files
committed
vtfpp/ImageConversion: disambiguate LERep conversions
1 parent 68905dc commit b0327c2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

include/vtfpp/ImageConversion.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class LERep : public std::array<std::byte, sizeof(A)> {
2727
uint16_t,
2828
uint8_t>::type>::type>::type;
2929
public:
30-
constexpr operator A() {
30+
constexpr operator A() const {
3131
uint_according ret = 0;
3232
for (size_t offs = 0; auto &b : *this) {
3333
ret |= (static_cast<uint_according>(b) << offs) & (uint_according(0xFFu) << offs);
@@ -44,11 +44,13 @@ class LERep : public std::array<std::byte, sizeof(A)> {
4444
return *this;
4545
}
4646
template<Arithmetic B> requires (std::convertible_to<B, A> || std::is_same_v<A, half>)
47-
constexpr LERep(const B &u) { *this = static_cast<A>(u); }
47+
constexpr LERep(const B &u) { this->operator=(static_cast<A>(u)); }
48+
4849
template<Arithmetic B> requires std::convertible_to<B, A>
49-
constexpr LERep(const LERep<B> &u) { *this = static_cast<A>(u); }
50+
constexpr LERep(const LERep<B> &u) { this->operator=(u.operator A()); }
51+
5052
template<Arithmetic B> requires std::convertible_to<A, B>
51-
constexpr operator B() const { return static_cast<B>(static_cast<A>(*this)); }
53+
constexpr operator B() const { return static_cast<B>(this->operator A()); }
5254
};
5355

5456
namespace ImagePixel {

0 commit comments

Comments
 (0)