- Timestamp:
- 11/26/20 01:12:15 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/nonstd_stl.h
r286 r1027 35 35 36 36 //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]; 39 39 40 40 // As litb noted in comments, you need this overload to handle array rvalues 41 41 // correctly (e.g. when array is a member of a struct returned from function), 42 42 // 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]; 45 45 46 46 //...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) 48 51 49 52
Note: See TracChangeset
for help on using the changeset viewer.