215 /////////////////////////////////////////
216 // Declare class constants.
217 /////////////////////////////////////////
218 const std::memory_order ATOMIC_MEMORY_ORDER_METHOD = std::memory_order_relaxed;219
220 /////////////////////////////////////////
221 // Declare private member variables.
38 std::chrono::high_resolution_clock::time_point m_tLastUpdateTime;
39
40 // Define class constants.
41 const long unsigned int m_nMaxMetricsHistorySize = 100; 42
43 /******************************************************************************
44 * @brief This method is used to calculate the IPS stats. Highest, lowest, and 1
194 * @author clayjay3 ([email protected])
195 * @date 2024-03-03
196 ******************************************************************************/
197 const std::function<void(const rovecomm::RoveCommPacket<uint8_t>&, const sockaddr_in&)> ClearWaypointsCallback =198 [this](const rovecomm::RoveCommPacket<uint8_t>& stPacket, const sockaddr_in& stdAddr)
199 {
200 // Not using this.
167 * @author clayjay3 ([email protected])
168 * @date 2024-03-03
169 ******************************************************************************/
170 const std::function<void(const rovecomm::RoveCommPacket<double>&, const sockaddr_in&)> AddObjectLegCallback =171 [this](const rovecomm::RoveCommPacket<double>& stPacket, const sockaddr_in& stdAddr)
172 {
173 // Not using this.
140 * @author clayjay3 ([email protected])
141 * @date 2024-03-03
142 ******************************************************************************/
143 const std::function<void(const rovecomm::RoveCommPacket<double>&, const sockaddr_in&)> AddMarkerLegCallback =144 [this](const rovecomm::RoveCommPacket<double>& stPacket, const sockaddr_in& stdAddr)
145 {
146 // Not using this.
Const or reference data members are only allowed to be initialized by the constructor of the class, and never after. And unlike in other languages, they are still instance dependent types. Having such members is rarely useful, and makes the class only copy-constructible but not copy-assignable.
That is to say, const data members will result in implicit deletion of copy and move assignment constructors.
If it was intended to be a constant value attached to the class
or struct
type itself consider using a static const member.
class Foo {
private:
const int bar;
int& ref_mem;
public:
Foo(int& ref_param): bar(10), ref_mem(ref_param) {}
};
class Foo {
private:
static const int bar = 10;
std::unique_ptr<int> mem;
public:
Foo(int param) {
bar = std::make_unique<int>(param);
}
};