#ifndef PFOR_PFOR_COMPARATORS_H #define PFOR_PFOR_COMPARATORS_H #include "mp/meta.h" #include "mp/pack.h" namespace pfor { /** * @brief compares two unsigned integers boxed in a type * * @param Lhs a boxed unsigned integer * @param Rhs a boxed unsigned integer * * @return Lhs < Rhs */ template struct ComparatorUIntToType; template struct ComparatorUIntToType, UIntToType> { static constexpr bool value = lhs < rhs; }; template constexpr bool comparatorUIntToType = ComparatorUIntToType::value; /** * @brief compares two packs of boxed unsigned integers * * @param Lhs a pack of boxed unsigned integer * @param Rhs a pack of boxed unsigned integer * * @return Lhs < Rhs */ template struct ComparatorUIntPack; template struct ComparatorUIntPack, As...>, Pack, Bs...>> { static constexpr bool value = a == b? ComparatorUIntPack, Pack>::value:(a < b); }; template struct ComparatorUIntPack, Pack...>> { static constexpr bool value = true; }; template struct ComparatorUIntPack...>, Pack<>> { static constexpr bool value = false; }; template<> struct ComparatorUIntPack, Pack<>> { static constexpr bool value = false; }; template constexpr bool comparatorUIntPack = ComparatorUIntPack::value; /** * @brief compares two expression's information (boxed integer, W, R) * * @param Lhs an expression's information * @param Rhs an expression's information * * @return Lhs < Rhs (using the boxed integer) */ template struct ComparatorExpressionInfo; template struct ComparatorExpressionInfo, W1, R1>, Pack, W2, R2>> { static constexpr bool value = i1 < i2; }; template constexpr bool comparatorExpressionInfo = ComparatorExpressionInfo::value; /** * @brief compares two written variables sets * * @param Lhs an expression's information * @param Rhs an expression's information * * @return Lhs < Rhs (using the W pack) */ template struct ComparatorWritePack; template struct ComparatorWritePack, Pack> { static constexpr bool value = comparatorUIntPack; }; template constexpr bool comparatorWritePack = ComparatorWritePack::value; } #endif