diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-02-01 10:51:29 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-02-01 10:51:29 +0000 |
commit | 3a469312a8069484b0efc4dad617c4a8a6fae8c1 (patch) | |
tree | 6a27602f6149ea1c70a414d657753fcef2f22e72 /eval | |
parent | 988fdfac3c51423aa4dd360693cfec7c985fcfb5 (diff) |
Add noexcept to move constructors and deinline destructor.
Diffstat (limited to 'eval')
-rw-r--r-- | eval/src/vespa/eval/eval/test/gen_spec.cpp | 20 | ||||
-rw-r--r-- | eval/src/vespa/eval/eval/test/gen_spec.h | 26 | ||||
-rw-r--r-- | eval/src/vespa/eval/gp/gp.cpp | 11 | ||||
-rw-r--r-- | eval/src/vespa/eval/gp/gp.h | 13 |
4 files changed, 45 insertions, 25 deletions
diff --git a/eval/src/vespa/eval/eval/test/gen_spec.cpp b/eval/src/vespa/eval/eval/test/gen_spec.cpp index 988ff035bbb..80cf91ed7e9 100644 --- a/eval/src/vespa/eval/eval/test/gen_spec.cpp +++ b/eval/src/vespa/eval/eval/test/gen_spec.cpp @@ -47,6 +47,22 @@ Sequence Seq(const std::vector<double> &seq) { //----------------------------------------------------------------------------- +DimSpec::DimSpec(const vespalib::string &name, size_t size) noexcept + : _name(name), _size(size), _dict() +{ + assert(_size); +} +DimSpec::DimSpec(const vespalib::string &name, std::vector<vespalib::string> dict) noexcept + : _name(name), _size(), _dict(std::move(dict)) +{ + assert(!_size); +} + +DimSpec::DimSpec(DimSpec &&) noexcept = default; +DimSpec::DimSpec(const DimSpec &) = default; +DimSpec & DimSpec::operator=(DimSpec &&) noexcept = default; +DimSpec & DimSpec::operator=(const DimSpec &) = default; + DimSpec::~DimSpec() = default; std::vector<vespalib::string> @@ -120,9 +136,9 @@ GenSpec::from_desc(const vespalib::string &desc) return {std::move(dim_list)}; } -GenSpec::GenSpec(GenSpec &&other) = default; +GenSpec::GenSpec(GenSpec &&other) noexcept = default; GenSpec::GenSpec(const GenSpec &other) = default; -GenSpec &GenSpec::operator=(GenSpec &&other) = default; +GenSpec &GenSpec::operator=(GenSpec &&other) noexcept = default; GenSpec &GenSpec::operator=(const GenSpec &other) = default; GenSpec::~GenSpec() = default; diff --git a/eval/src/vespa/eval/eval/test/gen_spec.h b/eval/src/vespa/eval/eval/test/gen_spec.h index 30893eb90a9..8a2a6ea12ec 100644 --- a/eval/src/vespa/eval/eval/test/gen_spec.h +++ b/eval/src/vespa/eval/eval/test/gen_spec.h @@ -56,16 +56,12 @@ private: size_t _size; std::vector<vespalib::string> _dict; public: - DimSpec(const vespalib::string &name, size_t size) noexcept - : _name(name), _size(size), _dict() - { - assert(_size); - } - DimSpec(const vespalib::string &name, std::vector<vespalib::string> dict) noexcept - : _name(name), _size(), _dict(std::move(dict)) - { - assert(!_size); - } + DimSpec(const vespalib::string &name, size_t size) noexcept; + DimSpec(const vespalib::string &name, std::vector<vespalib::string> dict) noexcept; + DimSpec(DimSpec &&) noexcept; + DimSpec & operator=(DimSpec &&) noexcept; + DimSpec & operator=(const DimSpec &); + DimSpec(const DimSpec &); ~DimSpec(); static std::vector<vespalib::string> make_dict(size_t size, size_t stride, const vespalib::string &prefix); ValueType::Dimension type() const { @@ -103,9 +99,9 @@ private: seq_t _seq; public: - GenSpec() : _dims(), _cells(CellType::DOUBLE), _seq(N()) {} - GenSpec(double bias) : _dims(), _cells(CellType::DOUBLE), _seq(N(bias)) {} - GenSpec(std::vector<DimSpec> dims_in) : _dims(std::move(dims_in)), _cells(CellType::DOUBLE), _seq(N()) {} + GenSpec() noexcept : _dims(), _cells(CellType::DOUBLE), _seq(N()) {} + GenSpec(double bias) noexcept : _dims(), _cells(CellType::DOUBLE), _seq(N(bias)) {} + GenSpec(std::vector<DimSpec> dims_in) noexcept : _dims(std::move(dims_in)), _cells(CellType::DOUBLE), _seq(N()) {} // Make a GenSpec object from a textual description // (dimension names must be single characters a-z) @@ -114,9 +110,9 @@ public: // 'a2_1b3_2c5_1' -> GenSpec().map("a", 2).map("b", 3, 2).map("c", 5); static GenSpec from_desc(const vespalib::string &desc); - GenSpec(GenSpec &&other); + GenSpec(GenSpec &&other) noexcept; GenSpec(const GenSpec &other); - GenSpec &operator=(GenSpec &&other); + GenSpec &operator=(GenSpec &&other) noexcept; GenSpec &operator=(const GenSpec &other); ~GenSpec(); const std::vector<DimSpec> &dims() const { return _dims; } diff --git a/eval/src/vespa/eval/gp/gp.cpp b/eval/src/vespa/eval/gp/gp.cpp index ca58907e320..f4c8796af23 100644 --- a/eval/src/vespa/eval/gp/gp.cpp +++ b/eval/src/vespa/eval/gp/gp.cpp @@ -28,6 +28,17 @@ Program::Ref map(const std::map<Program::Ref,Program::Ref> &ref_map, Program::Re } // namespace vespalib::gp::<unnamed> +Program::Program(Program &&) noexcept = default; +Program & Program::operator=(Program &&) noexcept = default; +Program::Program(const Program &) = default; +Program::~Program() = default; + +Program::Program(const OpRepo &repo, size_t in_cnt, size_t out_cnt, size_t alt_cnt, size_t gen) + : _repo(repo), _stats(gen), _waste(0.0), + _in_cnt(in_cnt), _out_cnt(out_cnt), _alt_cnt(alt_cnt), + _program(), _frozen(0), _bound() +{} + void Program::assert_valid(Ref ref, size_t limit) const { diff --git a/eval/src/vespa/eval/gp/gp.h b/eval/src/vespa/eval/gp/gp.h index cb5cb0d442e..ec27fa70d44 100644 --- a/eval/src/vespa/eval/gp/gp.h +++ b/eval/src/vespa/eval/gp/gp.h @@ -164,16 +164,13 @@ struct Program : public Sim { size_t rnd_op(Random &rnd) { return rnd.get(0, _repo.max_op()); } Ref rnd_ref(Random &rnd, size_t limit) { return Ref::rnd(rnd, _in_cnt, limit); } - Program(Program &&) = default; - Program &operator=(Program &&) = default; - Program(const Program &) = default; + Program(Program &&) noexcept; + Program &operator=(Program &&) noexcept; + Program(const Program &); Program &operator=(const Program &) = delete; - ~Program() {} + ~Program() override; - Program(const OpRepo &repo, size_t in_cnt, size_t out_cnt, size_t alt_cnt, size_t gen) - : _repo(repo), _stats(gen), _waste(0.0), - _in_cnt(in_cnt), _out_cnt(out_cnt), _alt_cnt(alt_cnt), - _program(), _frozen(0), _bound() {} + Program(const OpRepo &repo, size_t in_cnt, size_t out_cnt, size_t alt_cnt, size_t gen); Ref add_op(size_t code, Ref lhs, Ref rhs); Ref add_forward(Ref ref); |