From: Mikko Rasa Date: Wed, 15 Aug 2018 20:59:20 +0000 (+0300) Subject: Use covariant return type for Condition::clone X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=1805b8e549e6b5c0a53b2f735b8f2eb725f40b2e;p=poefilter.git Use covariant return type for Condition::clone --- diff --git a/source/choicecondition.h b/source/choicecondition.h index 6e2954d..170af0e 100644 --- a/source/choicecondition.h +++ b/source/choicecondition.h @@ -17,7 +17,7 @@ private: public: ChoiceCondition(Type); - virtual Condition *clone() const; + virtual ChoiceCondition *clone() const; virtual bool can_merge(const Condition &, const CompoundCondition &) const; virtual void add_lines(std::list &) const; virtual void add_merged_lines(const std::vector &, const CompoundCondition &, std::list &) const; @@ -48,9 +48,9 @@ ChoiceCondition::ChoiceCondition(Type v): { } template -Condition *ChoiceCondition::clone() const +ChoiceCondition *ChoiceCondition::clone() const { - return new ChoiceCondition(values); + return new ChoiceCondition(value); } template diff --git a/source/condition.cpp b/source/condition.cpp index 9ff02aa..be5a29f 100644 --- a/source/condition.cpp +++ b/source/condition.cpp @@ -22,7 +22,7 @@ void CompoundCondition::add(Condition *cond) } -Condition *AndCondition::clone() const +AndCondition *AndCondition::clone() const { AndCondition *result = new AndCondition; clone_to(*result); @@ -36,7 +36,7 @@ void AndCondition::add_lines(list &st) const } -Condition *OrCondition::clone() const +OrCondition *OrCondition::clone() const { OrCondition *result = new OrCondition; clone_to(*result); @@ -69,7 +69,7 @@ LinkedColorsCondition::LinkedColorsCondition(const Colors &c): colors(c) { } -Condition *LinkedColorsCondition::clone() const +LinkedColorsCondition *LinkedColorsCondition::clone() const { return new LinkedColorsCondition(colors); } diff --git a/source/condition.h b/source/condition.h index 90c844e..53f2a8a 100644 --- a/source/condition.h +++ b/source/condition.h @@ -43,7 +43,7 @@ public: class AndCondition: public CompoundCondition { public: - virtual Condition *clone() const; + virtual AndCondition *clone() const; virtual void add_lines(std::list &) const; }; @@ -51,7 +51,7 @@ public: class OrCondition: public CompoundCondition { public: - virtual Condition *clone() const; + virtual OrCondition *clone() const; virtual void add_lines(std::list &) const; }; @@ -70,7 +70,7 @@ private: public: LinkedColorsCondition(const Colors &); - virtual Condition *clone() const; + virtual LinkedColorsCondition *clone() const; virtual void add_lines(std::list &) const; }; diff --git a/source/rangecondition.h b/source/rangecondition.h index c107287..0d93994 100644 --- a/source/rangecondition.h +++ b/source/rangecondition.h @@ -19,7 +19,7 @@ public: RangeCondition(Type); RangeCondition(Type, Type); - virtual Condition *clone() const; + virtual RangeCondition *clone() const; virtual void add_lines(std::list &) const; }; @@ -125,7 +125,7 @@ RangeCondition::RangeCondition(Type n, Type x): { } template -Condition *RangeCondition::clone() const +RangeCondition *RangeCondition::clone() const { return new RangeCondition(min, max); }