Ignore:
Timestamp:
07/11/24 17:59:38 (3 months ago)
Author:
Maciej Komosinski
Message:

Cosmetic

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/common/nonstd_math.h

    r1302 r1318  
    2525inline double rndDouble(double limit_exclusive) { return rndGetInstance().getDouble() * limit_exclusive; }
    2626inline unsigned int rndUint(unsigned int limit_exclusive) { return (unsigned int)(rndGetInstance().getDouble() * limit_exclusive); } //returns random from 0..limit_exclusive-1
    27 #ifndef __BORLANDC__ //for embarcadero 11u3, unsigned int and size_t are duplicates
    28 inline unsigned int rndUint(size_t limit_exclusive) {return rndUint((unsigned int)limit_exclusive);} //just an overload with size_t argument
     27#if !defined __BORLANDC__ && !defined __ARM_ARCH_7A__ //for 32-bit compilations (embarcadero 11u3 and clang android), unsigned int and size_t function variants are duplicates. Using templates to define an additional function variant only when size_t is different from unsigned int is such a hassle... especially that some variants are inline, some are not. Another approach would be to create a template for all types (or all integer types?) and potentially getting an overflow for longer int types when casting the result of getDouble()*limit_exclusive to unsigned int.
     28inline unsigned int rndUint(size_t limit_exclusive) {return rndUint((unsigned int)limit_exclusive);} //just an overload with size_t argument to avoid compiler warnings and avoid hundreds of casts. May limit the range if size_t is larger than unsigned int and somebody would intentionally use such a huge limit_exclusive value.
    2929#endif
    3030unsigned int rndUint(int limit_exclusive); //just an overload with int argument
Note: See TracChangeset for help on using the changeset viewer.