DiSMEC++
types.h
Go to the documentation of this file.
1 // Copyright (c) 2021, Aalto University, developed by Erik Schultheis
2 // All rights reserved.
3 //
4 // SPDX-License-Identifier: MIT
5 
6 #ifndef DISMEC_TYPES_H
7 #define DISMEC_TYPES_H
8 
9 #include "utils/opaque_int.h"
10 
11 namespace dismec
12 {
13  // forward declarations
14  class DatasetBase;
15 
20  class label_id_t : public opaque_int_type<label_id_t, std::int_fast32_t> {
21  public:
23 
24  inline label_id_t& operator++() {
25  ++m_Value;
26  return *this;
27  }
28  };
29 
30  inline std::ptrdiff_t operator-(label_id_t a, label_id_t b) {
31  return a.to_index() - b.to_index();
32  }
33 
34  inline label_id_t operator+(label_id_t a, std::ptrdiff_t b) {
35  return label_id_t{a.to_index() + b};
36  }
37 }
38 
39 #endif //DISMEC_TYPES_H
Strong typedef for an int to signify a label id.
Definition: types.h:20
label_id_t & operator++()
Definition: types.h:24
An integer-like type that represents categorical values.
Definition: opaque_int.h:24
constexpr opaque_int_type(T v) noexcept
! Explicit constructor from an underlying int.
Definition: opaque_int.h:29
constexpr T to_index() const
! Explicitly convert to an integer.
Definition: opaque_int.h:32
Main namespace in which all types, classes, and functions are defined.
Definition: app.h:15
std::ptrdiff_t operator-(label_id_t a, label_id_t b)
Definition: types.h:30
label_id_t operator+(label_id_t a, std::ptrdiff_t b)
Definition: types.h:34