Program Listing for File Velocity.hpp

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

#ifndef LOULIB_VELOCITY_HPP
#define LOULIB_VELOCITY_HPP

#include "BaseUnit.hpp"
#include "UnitMath.hpp"
#include "Length.hpp"
#include "Time.hpp"

namespace LouLib{
    namespace Units{
        DEFINE_NEW_UNIT(1, 0, -1, 0, 0, 0, 0, 0, Velocity);

        constexpr Velocity METER_PER_SECOND = METER / SECOND;
        constexpr Velocity FOOT_PER_SECOND = FOOT / SECOND;

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

            CREATE_VELOCITY_STRING_LITERAL(_mps, METER_PER_SECOND);
            CREATE_VELOCITY_STRING_LITERAL(_fps, FOOT_PER_SECOND);
        }
    }
}

#endif //LOULIB_VELOCITY_HPP