2021-05-11 09:52:00 -07:00
|
|
|
|
|
|
|
|
// A Scalar with internal representation T+1 so that zero is internally
|
|
|
|
|
// represented by T(1). This is used to test memory fill.
|
|
|
|
|
//
|
2023-05-05 17:30:36 +00:00
|
|
|
#pragma once
|
2021-05-11 09:52:00 -07:00
|
|
|
template <typename T>
|
|
|
|
|
class OffByOneScalar {
|
|
|
|
|
public:
|
|
|
|
|
OffByOneScalar() : val_(1) {}
|
2023-05-05 17:30:36 +00:00
|
|
|
OffByOneScalar(const OffByOneScalar& other) = default;
|
|
|
|
|
OffByOneScalar& operator=(const OffByOneScalar& other) = default;
|
2023-12-05 21:22:55 +00:00
|
|
|
|
2021-05-11 09:52:00 -07:00
|
|
|
OffByOneScalar(T val) : val_(val + 1) {}
|
|
|
|
|
OffByOneScalar& operator=(T val) { val_ = val + 1; }
|
2023-12-05 21:22:55 +00:00
|
|
|
|
2021-05-11 09:52:00 -07:00
|
|
|
operator T() const { return val_ - 1; }
|
2023-12-05 21:22:55 +00:00
|
|
|
|
2021-05-11 09:52:00 -07:00
|
|
|
private:
|
|
|
|
|
T val_;
|
|
|
|
|
};
|