feat(const): updated const to be truly immutable

This commit is contained in:
2025-02-12 11:16:40 -05:00
parent fbd3c3ad58
commit 4227eacd5b
2 changed files with 30 additions and 20 deletions

View File

@@ -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.