Changeset 1027 for cpp


Ignore:
Timestamp:
11/26/20 01:12:15 (4 years ago)
Author:
Maciej Komosinski
Message:

#defined ARRAY_LENGTH(x) replaced by std::size(x) since C++17

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/common/nonstd_stl.h

    r286 r1027  
    3535
    3636//szablony hakerskie: tablica bajtow o dlugosci N - tak dluga jak tablica o któr¹ pytamy...
    37 template <typename T, std::size_t N>
    38 char (&array_temp(T (&a)[N]))[N];
     37//template <typename T, std::size_t N>
     38//char (&array_temp(T (&a)[N]))[N];
    3939
    4040// As litb noted in comments, you need this overload to handle array rvalues
    4141// correctly (e.g. when array is a member of a struct returned from function),
    4242// since they won't bind to non-const reference in the overload above.
    43 template <typename T, std::size_t N>
    44 char (&array_temp(const T (&a)[N]))[N];
     43//template <typename T, std::size_t N>
     44//char (&array_temp(const T (&a)[N]))[N];
    4545
    4646//...ktor¹ mozna potem uzyc normalnie w sizeof i dzieki temu mamy const w compile-time. tak uzyteczne jak staromodne makro ale z pelna kontrola bledow
    47 #define ARRAY_LENGTH(x) sizeof(array_temp(x))
     47//#define ARRAY_LENGTH(x) sizeof(array_temp(x))
     48
     49//final and no longer needed version ;-) (c++17)
     50#define ARRAY_LENGTH(x) std::size(x)
    4851
    4952
Note: See TracChangeset for help on using the changeset viewer.