feat(const): updated const to be truly immutable
This commit is contained in:
@@ -11,11 +11,22 @@
|
||||
* @brief Structure to hold a constant's details.
|
||||
*/
|
||||
struct constant {
|
||||
std::string name; ///< Name of the constant
|
||||
double value; ///< Value of the constant
|
||||
double uncertainty; ///< Uncertainty in the constant's value
|
||||
std::string unit; ///< Unit of the constant
|
||||
std::string reference; ///< Reference for the constant's value
|
||||
const std::string name; ///< Name of the constant
|
||||
const double value; ///< Value of the constant
|
||||
const double uncertainty; ///< Uncertainty in the constant's value
|
||||
const std::string unit; ///< Unit of the constant
|
||||
const std::string reference; ///< Reference for the constant's value
|
||||
|
||||
/**
|
||||
* @brief Parameterized constructor.
|
||||
* @param name The name of the constant.
|
||||
* @param value The value of the constant.
|
||||
* @param uncertainty The uncertainty in the constant's value.
|
||||
* @param unit The unit of the constant.
|
||||
* @param reference The reference for the constant's value.
|
||||
*/
|
||||
constant(const std::string& name, double value, double uncertainty, const std::string& unit, const std::string& reference)
|
||||
: name(name), value(value), uncertainty(uncertainty), unit(unit), reference(reference) {}
|
||||
|
||||
/**
|
||||
* @brief overload the << operator for pretty printing
|
||||
@@ -81,7 +92,7 @@ public:
|
||||
* @param key The name of the constant to retrieve.
|
||||
* @return The constant associated with the given key.
|
||||
*/
|
||||
constant get(const std::string& key);
|
||||
constant get(const std::string& key) const;
|
||||
|
||||
/**
|
||||
* @brief Overloaded subscript operator to access constants by key.
|
||||
|
||||
Reference in New Issue
Block a user