From d999415c3d05c0cd2e7221069fb39b7eff286781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Tue, 11 Apr 2017 15:55:31 +0200 Subject: [PATCH] Enforcing move semantics on all AST elements explicitly. --- include/anthem/AST.h | 95 ++++++++++++++++++++++++++++++++++++++++++++ lib/clingo | 2 +- 2 files changed, 96 insertions(+), 1 deletion(-) diff --git a/include/anthem/AST.h b/include/anthem/AST.h index f12a5a8..51e3ac2 100644 --- a/include/anthem/AST.h +++ b/include/anthem/AST.h @@ -35,6 +35,11 @@ struct BinaryOperation Modulo }; + BinaryOperation(const BinaryOperation &other) = delete; + BinaryOperation &operator=(const BinaryOperation &other) = delete; + BinaryOperation(BinaryOperation &&other) noexcept = default; + BinaryOperation &operator=(BinaryOperation &&other) noexcept = default; + BinaryOperation(Operator operator_, Term &&left, Term &&right) : operator_{operator_}, left{std::move(left)}, @@ -56,6 +61,11 @@ struct Boolean { } + Boolean(const Boolean &other) = delete; + Boolean &operator=(const Boolean &other) = delete; + Boolean(Boolean &&other) noexcept = default; + Boolean &operator=(Boolean &&other) noexcept = default; + bool value = false; }; @@ -80,6 +90,11 @@ struct Comparison { } + Comparison(const Comparison &other) = delete; + Comparison &operator=(const Comparison &other) = delete; + Comparison(Comparison &&other) noexcept = default; + Comparison &operator=(Comparison &&other) noexcept = default; + Operator operator_; Term left; Term right; @@ -94,6 +109,11 @@ struct Constant { } + Constant(const Constant &other) = delete; + Constant &operator=(const Constant &other) = delete; + Constant(Constant &&other) noexcept = default; + Constant &operator=(Constant &&other) noexcept = default; + std::string name; }; @@ -112,6 +132,11 @@ struct Function { } + Function(const Function &other) = delete; + Function &operator=(const Function &other) = delete; + Function(Function &&other) noexcept = default; + Function &operator=(Function &&other) noexcept = default; + std::string name; std::vector arguments; }; @@ -129,6 +154,11 @@ struct In assert(isPrimitive(element)); } + In(const In &other) = delete; + In &operator=(const In &other) = delete; + In(In &&other) noexcept = default; + In &operator=(In &&other) noexcept = default; + Term element; Term set; }; @@ -142,6 +172,11 @@ struct Integer { } + Integer(const Integer &other) = delete; + Integer &operator=(const Integer &other) = delete; + Integer(Integer &&other) noexcept = default; + Integer &operator=(Integer &&other) noexcept = default; + int value; }; @@ -155,6 +190,11 @@ struct Interval { } + Interval(const Interval &other) = delete; + Interval &operator=(const Interval &other) = delete; + Interval(Interval &&other) noexcept = default; + Interval &operator=(Interval &&other) noexcept = default; + Term from; Term to; }; @@ -174,6 +214,11 @@ struct Predicate { } + Predicate(const Predicate &other) = delete; + Predicate &operator=(const Predicate &other) = delete; + Predicate(Predicate &&other) noexcept = default; + Predicate &operator=(Predicate &&other) noexcept = default; + std::size_t arity() const { return arguments.size(); @@ -198,6 +243,11 @@ struct SpecialInteger { } + SpecialInteger(const SpecialInteger &other) = delete; + SpecialInteger &operator=(const SpecialInteger &other) = delete; + SpecialInteger(SpecialInteger &&other) noexcept = default; + SpecialInteger &operator=(SpecialInteger &&other) noexcept = default; + Type type; }; @@ -210,6 +260,11 @@ struct String { } + String(const String &other) = delete; + String &operator=(const String &other) = delete; + String(String &&other) noexcept = default; + String &operator=(String &&other) noexcept = default; + std::string text; }; @@ -229,6 +284,11 @@ struct Variable { } + Variable(const Variable &other) = delete; + Variable &operator=(const Variable &other) = delete; + Variable(Variable &&other) noexcept = default; + Variable &operator=(Variable &&other) noexcept = default; + std::string name; Type type; }; @@ -246,6 +306,11 @@ struct And { } + And(const And &other) = delete; + And &operator=(const And &other) = delete; + And(And &&other) noexcept = default; + And &operator=(And &&other) noexcept = default; + std::vector arguments; }; @@ -259,6 +324,11 @@ struct Biconditional { } + Biconditional(const Biconditional &other) = delete; + Biconditional &operator=(const Biconditional &other) = delete; + Biconditional(Biconditional &&other) noexcept = default; + Biconditional &operator=(Biconditional &&other) noexcept = default; + Formula left; Formula right; }; @@ -273,6 +343,11 @@ struct Exists { } + Exists(const Exists &other) = delete; + Exists &operator=(const Exists &other) = delete; + Exists(Exists &&other) noexcept = default; + Exists &operator=(Exists &&other) noexcept = default; + std::vector variables; Formula argument; }; @@ -287,6 +362,11 @@ struct ForAll { } + ForAll(const ForAll &other) = delete; + ForAll &operator=(const ForAll &other) = delete; + ForAll(ForAll &&other) noexcept = default; + ForAll &operator=(ForAll &&other) noexcept = default; + std::vector variables; Formula argument; }; @@ -301,6 +381,11 @@ struct Implies { } + Implies(const Implies &other) = delete; + Implies &operator=(const Implies &other) = delete; + Implies(Implies &&other) noexcept = default; + Implies &operator=(Implies &&other) noexcept = default; + Formula antecedent; Formula consequent; }; @@ -314,6 +399,11 @@ struct Not { } + Not(const Not &other) = delete; + Not &operator=(const Not &other) = delete; + Not(Not &&other) noexcept = default; + Not &operator=(Not &&other) noexcept = default; + Formula argument; }; @@ -328,6 +418,11 @@ struct Or { } + Or(const Or &other) = delete; + Or &operator=(const Or &other) = delete; + Or(Or &&other) noexcept = default; + Or &operator=(Or &&other) noexcept = default; + std::vector arguments; }; diff --git a/lib/clingo b/lib/clingo index a49d599..207bc0a 160000 --- a/lib/clingo +++ b/lib/clingo @@ -1 +1 @@ -Subproject commit a49d599c0edd11bf57b41d16585cc698e188aecc +Subproject commit 207bc0a6d3e0e7d2704744718adb460daa94c732