Home » Community » U++ community news and announcements » get_i
Re: get_i [message #54250 is a reply to message #54247] |
Tue, 16 June 2020 17:45   |
Novo
Messages: 1430 Registered: December 2006
|
Ultimate Contributor |
|
|
Thank you.
I played a little bit with get_i and godbolt.org and got results below.
Test: const char* c = get_i(-1, "zero", "one", "two");
Assembly for the original code (-O2):
.LC0:
.string "zero"
_GLOBAL__sub_I_c:
mov QWORD PTR c[rip], OFFSET FLAT:.LC0
ret
c:
.zero 8
I changes U++ code a little bit:
template <class T> constexpr const T& min(const T& a, const T& b) { return a < b ? a : b; }
template <class T> constexpr const T& max(const T& a, const T& b) { return a > b ? a : b; }
template <class T> // deprecated name, use clamp
constexpr T minmax(T x, T _min, T _max) { return min(max(x, _min), _max); }
template <class T>
constexpr T clamp(T x, T _min, T _max) { return minmax(x, _min, _max); }
inline constexpr const char *get_i(int i, const char *p0, __List##I(E__NFValue)) \
Resulting assenbly:
.LC0:
.string "zero"
c:
.quad .LC0
Conclusion: "constexpr" is quite useful ...
Regards,
Novo
|
|
|
 |
|
get_i
By: mirek on Sun, 14 June 2020 19:10
|
 |
|
Re: get_i
By: Novo on Tue, 16 June 2020 17:45
|
 |
|
Re: get_i
By: mirek on Tue, 16 June 2020 17:52
|
 |
|
Re: get_i
By: Novo on Tue, 16 June 2020 18:02
|
 |
|
Re: get_i
By: Novo on Tue, 16 June 2020 18:21
|
 |
|
Re: get_i
By: mirek on Tue, 16 June 2020 21:20
|
 |
|
Re: get_i
By: Novo on Tue, 16 June 2020 22:15
|
 |
|
Re: get_i
By: mirek on Wed, 17 June 2020 00:01
|
 |
|
Re: get_i
By: Novo on Wed, 17 June 2020 07:01
|
 |
|
Re: get_i
By: Novo on Wed, 17 June 2020 07:09
|
 |
|
Re: get_i
By: Novo on Wed, 17 June 2020 07:23
|
 |
|
Re: get_i
By: Novo on Wed, 17 June 2020 07:50
|
 |
|
Re: get_i
By: mirek on Wed, 17 June 2020 09:35
|
 |
|
Re: get_i
By: mirek on Wed, 17 June 2020 13:03
|
 |
|
Re: get_i
By: Novo on Wed, 17 June 2020 19:00
|
 |
|
Re: get_i
By: Novo on Wed, 17 June 2020 19:14
|
 |
|
Re: get_i
By: mirek on Wed, 17 June 2020 21:03
|
 |
|
Re: get_i
By: Novo on Wed, 17 June 2020 23:21
|
 |
|
Re: get_i
By: Novo on Wed, 17 June 2020 23:59
|
 |
|
Re: get_i
By: mirek on Thu, 18 June 2020 08:39
|
 |
|
Re: get_i
By: Novo on Thu, 18 June 2020 23:56
|
 |
|
Re: get_i
By: Novo on Tue, 16 June 2020 21:22
|
 |
|
Re: get_i
By: mirek on Tue, 16 June 2020 21:25
|
 |
|
Re: get_i
By: Novo on Tue, 16 June 2020 21:42
|
 |
|
Re: get_i
By: Novo on Wed, 17 June 2020 06:39
|
 |
|
Re: get_i
By: mirek on Mon, 29 June 2020 19:23
|
 |
|
Re: get_i
By: Novo on Thu, 02 July 2020 22:08
|
 |
|
Re: get_i
By: mirek on Fri, 03 July 2020 09:38
|
 |
|
Re: get_i
By: Novo on Fri, 03 July 2020 18:53
|
 |
|
Re: get_i
By: mirek on Fri, 03 July 2020 19:03
|
Goto Forum:
Current Time: Wed Apr 30 00:56:42 CEST 2025
Total time taken to generate the page: 0.05216 seconds
|