Skip to content

Commit

Permalink
r.terrafow: explicit use of default constructors (OSGeo#2660)
Browse files Browse the repository at this point in the history
Fixes -Wclass-memaccess and -Wdeprecated-declaration warnings.

Use 'default' for implicitly-declared constructors and use default
(implicit) destructor.

Simplify; modernise constructs.
  • Loading branch information
nilason authored and neteler committed Nov 7, 2023
1 parent 31052df commit 5fe6048
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 49 deletions.
11 changes: 5 additions & 6 deletions raster/r.terraflow/ccforest.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ class keyvalue {
T src() const { return key; };
T dst() const { return value; };

keyvalue operator=(const keyvalue &that)
{
key = that.key;
value = that.value;
return *this;
};
int operator!=(const keyvalue &e2) const
{
return (key != e2.key) || (value != e2.value);
Expand Down Expand Up @@ -147,7 +141,12 @@ class ccforest {

public:
ccforest();
ccforest(const ccforest &) = delete;
ccforest &operator=(const ccforest &) = delete;
ccforest(ccforest &&) = delete;
ccforest &operator=(ccforest &&) = delete;
~ccforest();

void insert(const T &i, const T &j); /* insert edge (i,j) */
T findNextRoot(const T &i); /* find root where i >= prev i */
void printRootStream();
Expand Down
8 changes: 0 additions & 8 deletions raster/r.terraflow/genericWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,6 @@ class genericWindow {
}
}

/***************************************************************/
genericWindow(const genericWindow<T> &win)
{
for (int i = 0; i < 9; i++) {
data[i] = win.data[i];
}
}

/***************************************************************/
/* get specified neighbour di,dj in {-1,0,1} */
T get(short di, short dj) const
Expand Down
55 changes: 20 additions & 35 deletions raster/r.terraflow/sweep.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,27 +160,28 @@ class gridPosition {
/*************************************************************/
class flowPriority {
public:
elevation_type h;
toporank_type toporank;
elevation_type h{0.0};
toporank_type toporank{0};
/* points at same heights are processed in increasing order of their
topological rank; overall, this gives topological order and
guarantees that flow is never puhsed backwards. Note: of course,
this is a way of waving hands on topological sorting. */
dimension_type i, j;
dimension_type i{0}, j{0};

public:
flowPriority(elevation_type a = 0, toporank_type b = 0,
dimension_type c = 0, dimension_type d = 0)
: h(a), toporank(b), i(c), j(d)
{
}

flowPriority(const flowPriority &p)
: h(p.h), toporank(p.toporank), i(p.i), j(p.j)
flowPriority() {}
flowPriority(elevation_type a) : h{a} {}
flowPriority(elevation_type a, toporank_type b, dimension_type c,
dimension_type d)
: h{a}, toporank{b}, i{c}, j{d}
{
}

~flowPriority() {}
flowPriority(const flowPriority &) = default;
flowPriority &operator=(const flowPriority &) = default;
flowPriority(flowPriority &&) = default;
flowPriority &operator=(flowPriority &&) = default;
~flowPriority() = default;

elevation_type field1() const { return h; }

Expand Down Expand Up @@ -312,9 +313,6 @@ class sweepItemBaseType {
{
}

/***************************************************************/
~sweepItemBaseType() {}

/***************************************************************/
/* return the elevation window */
genericWindow<elevation_type> getElevWindow() const { return elevwin; }
Expand Down Expand Up @@ -413,12 +411,11 @@ class PrioCmpSweepItem {
/************************************************************/
class flowValue {
public:
flowaccumulation_type value;
flowaccumulation_type value{0};

public:
flowValue(flowaccumulation_type x = 0) : value(x) {}

~flowValue() {}
flowValue() {}
flowValue(flowaccumulation_type x) : value{x} {}

flowaccumulation_type get() const { return value; }
friend ostream &operator<<(ostream &s, const flowValue &elt)
Expand All @@ -434,11 +431,6 @@ class flowValue {
flowValue elt(elt1.value + elt2.value);
return elt;
}
flowValue operator=(const flowValue &elt)
{
value = elt.value;
return *this;
}
flowValue operator!=(const flowValue &elt) { return value != elt.value; }
flowValue operator==(const flowValue &elt) { return value == elt.value; }

Expand All @@ -463,22 +455,15 @@ class flowValue {
/************************************************************/
class flowStructure {
private:
flowPriority prio;
flowValue val;
flowPriority prio{};
flowValue val{};

public:
flowStructure(const flowPriority &p = 0, const flowValue &e = 0)
: prio(p), val(e)
flowStructure() {}
flowStructure(const flowPriority &p, const flowValue &e) : prio{p}, val{e}
{
}

/* flowStructure(const flowValue &e, const flowPriority &p):
prio(p), val(e) {}
*/
flowStructure(const flowStructure &fl) : prio(fl.prio), val(fl.val) {}

~flowStructure() {}

flowPriority getPriority() const { return prio; }

flowValue getValue() const { return val; }
Expand Down

0 comments on commit 5fe6048

Please sign in to comment.