1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-04 18:29:40 +00:00

Extended both classes to allow copy assignment, copy construction and implicit zero-length construction.

This commit is contained in:
Thomas Harte 2017-07-23 22:13:41 -04:00
parent 6369138bd1
commit 8a0b0cb3d7

View File

@ -13,8 +13,15 @@
class Cycles {
public:
Cycles(int l) : length_(l) {}
Cycles(const Cycles &cycles) : length_(int(cycles)) {}
Cycles() : length_(0) {}
operator int() const { return length_; }
Cycles &operator =(const Cycles &cycles) {
length_ = cycles.length_;
return *this;
}
private:
int length_;
};
@ -24,6 +31,14 @@ class HalfCycles {
public:
HalfCycles(int l) : length_(l) {}
HalfCycles(const Cycles &cycles) : length_(int(cycles) << 1) {}
HalfCycles(const HalfCycles &half_cycles) : length_(int(half_cycles)) {}
HalfCycles() : length_(0) {}
HalfCycles &operator =(const HalfCycles &half_cycles) {
length_ = half_cycles.length_;
return *this;
}
operator int() const { return length_; }
private: