Program Listing for File Temperature.hpp

Return to documentation for file (src/LouLib/Units/Temperature.hpp)

#ifndef LOULIB_TEMPERATURE_HPP
#define LOULIB_TEMPERATURE_HPP

#include "BaseUnit.hpp"
#include "UnitMath.hpp"

namespace LouLib {
    namespace Units {
        DEFINE_NEW_UNIT(0, 0, 0, 0, 1, 0, 0, 0, Temperature);

        //base unit
        constexpr Temperature KELVIN(1.0);

        inline namespace literals{
            #define CREATE_TEMPERATURE_STRING_LITERAL(literal, unit)             \
            constexpr Temperature operator"" literal(long double x){             \
                return static_cast<double>(x)*unit;                         \
            }                                                               \
            constexpr Temperature operator"" literal(unsigned long long int x){  \
                return static_cast<double>(x)*unit;                         \
            }

            CREATE_TEMPERATURE_STRING_LITERAL(_K, KELVIN);
        }
    }
}

#endif //LOULIB_TEMPERATURE_HPP