Changeset 1157


Ignore:
Timestamp:
Mar 12, 2012, 2:57:07 AM (10 years ago)
Author:
sam
Message:

math: minor tweak to avoid using macros with empty parameters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lol/math/vector.h

    r1154 r1157  
    954954#define DECLARE_VECTOR_VECTOR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \
    955955    tprefix \
    956     static inline tname<tf> operator op(tname<t1> const &a, \
    957                                         tname<t2> const &b) \
     956    inline tname<tf> operator op(tname<t1> const &a, tname<t2> const &b) \
    958957    { \
    959958        tname<tf> ret; \
     
    965964#define DECLARE_VECTOR_VECTOR_OP(tname, op, tprefix, type) \
    966965    tprefix \
    967     static inline tname<type> operator op##=(tname<type> &a, \
    968                                              tname<type> const &b) \
     966    inline tname<type> operator op##=(tname<type> &a, tname<type> const &b) \
    969967    { \
    970968        return a = a op b; \
     
    973971#define DECLARE_VECTOR_VECTOR_BOOLOP(tname, op, op2, ret, tprefix, t1, t2) \
    974972    tprefix \
    975     static inline bool operator op(tname<t1> const &a, \
    976                                    tname<t2> const &b) \
     973    inline bool operator op(tname<t1> const &a, tname<t2> const &b) \
    977974    { \
    978975        for (size_t n = 0; n < sizeof(a) / sizeof(t1); n++) \
     
    984981#define DECLARE_VECTOR_SCALAR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \
    985982    tprefix \
    986     static inline tname<tf> operator op(tname<t1> const &a, t2 const &val) \
     983    inline tname<tf> operator op(tname<t1> const &a, t2 const &val) \
    987984    { \
    988985        tname<tf> ret; \
     
    993990    \
    994991    tprefix \
    995     static inline tname<tf> operator op(t1 const &val, tname<t2> const &a) \
     992    inline tname<tf> operator op(t1 const &val, tname<t2> const &a) \
    996993    { \
    997994        tname<tf> ret; \
     
    10031000#define DECLARE_VECTOR_SCALAR_OP(tname, op, tprefix, type) \
    10041001    tprefix \
    1005     static inline tname<type> operator op##=(tname<type> &a, type const &val) \
     1002    inline tname<type> operator op##=(tname<type> &a, type const &val) \
    10061003    { \
    10071004        return a = a op val; \
     
    10101007#define DECLARE_UNARY_OPS(tname, tprefix, type) \
    10111008    tprefix \
    1012     static inline tname<type> operator -(tname<type> const &a) \
     1009    inline tname<type> operator -(tname<type> const &a) \
    10131010    { \
    10141011        tname<type> ret; \
     
    10191016    \
    10201017    tprefix \
    1021     static inline type sqlen(tname<type> const &a) \
     1018    inline type sqlen(tname<type> const &a) \
    10221019    { \
    10231020        type acc = 0; \
     
    10281025    \
    10291026    tprefix \
    1030     static inline double len(tname<type> const &a) \
     1027    inline double len(tname<type> const &a) \
    10311028    { \
    10321029        using namespace std; \
     
    10351032    \
    10361033    tprefix \
    1037     static inline tname<type> normalize(tname<type> const &val) \
     1034    inline tname<type> normalize(tname<type> const &val) \
    10381035    { \
    10391036        type norm = (type)len(val); \
     
    10521049    \
    10531050    tprefix \
    1054     static inline tf dot(tname<t1> const &a, tname<t2> const &b) \
     1051    inline tf dot(tname<t1> const &a, tname<t2> const &b) \
    10551052    { \
    10561053        tf ret = 0; \
     
    10791076
    10801077#define DECLARE_VECTOR_OPS(tname, tprefix, type) \
    1081     DECLARE_VECTOR_COERCE_OPS(tname, /* empty */, type, type, type) \
     1078    DECLARE_VECTOR_COERCE_OPS(tname, static, type, type, type) \
    10821079    \
    10831080    DECLARE_VECTOR_VECTOR_OP(tname, *, tprefix, type) \
     
    10851082
    10861083#define DECLARE_ALL_NONVECTOR_OPS(tname) \
    1087     DECLARE_BINARY_OPS(tname, template<typename T>, T) \
    1088     DECLARE_UNARY_OPS(tname, template<typename T>, T)
     1084    DECLARE_BINARY_OPS(tname, template<typename T> static, T) \
     1085    DECLARE_UNARY_OPS(tname, template<typename T> static, T)
    10891086
    10901087#define DECLARE_ALL_VECTOR_OPS_INNER(tname, type) \
    1091     DECLARE_BINARY_OPS(tname, /* empty */, type) \
    1092     DECLARE_UNARY_OPS(tname, /* empty */, type) \
    1093     DECLARE_VECTOR_OPS(tname, /* empty */, type) \
     1088    DECLARE_BINARY_OPS(tname, static, type) \
     1089    DECLARE_UNARY_OPS(tname, static, type) \
     1090    DECLARE_VECTOR_OPS(tname, static, type) \
    10941091
    10951092#define DECLARE_ALL_VECTOR_OPS(tname) \
     
    11071104
    11081105#define DECLARE_ALL_VECTOR_COERCE_OPS_INNER(tname, tlow, thigh) \
    1109     DECLARE_BINARY_COERCE_OPS(tname, /* empty */, tlow, thigh, thigh) \
    1110     DECLARE_BINARY_COERCE_OPS(tname, /* empty */, thigh, tlow, thigh) \
    1111     \
    1112     DECLARE_VECTOR_COERCE_OPS(tname, /* empty */, tlow, thigh, thigh) \
    1113     DECLARE_VECTOR_COERCE_OPS(tname, /* empty */, thigh, tlow, thigh)
     1106    DECLARE_BINARY_COERCE_OPS(tname, static, tlow, thigh, thigh) \
     1107    DECLARE_BINARY_COERCE_OPS(tname, static, thigh, tlow, thigh) \
     1108    \
     1109    DECLARE_VECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \
     1110    DECLARE_VECTOR_COERCE_OPS(tname, static, thigh, tlow, thigh)
    11141111
    11151112#define DECLARE_ALL_VECTOR_COERCE_OPS(tname) \
Note: See TracChangeset for help on using the changeset viewer.