Home » Community » U++ community news and announcements » get_i
Re: get_i [message #54268 is a reply to message #54267] |
Wed, 17 June 2020 13:03   |
 |
mirek
Messages: 14256 Registered: November 2005
|
Ultimate Member |
|
|
So I started looking into eliminating all instances of Expand macro usage and identified that following helpers could be quite useful:
template <class I, class V>
void iter_set(I t, V&& v)
{
*t++ = v;
}
template <class I, class V, typename... Args>
void iter_set(I t, V&& v, Args&& ...args)
{
*t++ = v;
iter_set(t, args...);
}
template <class C, typename... Args>
C gather(Args&& ...args)
{
C x;
x.SetCount(sizeof...(args));
iter_set(x.begin(), args...);
return x;
}
template <class I, class V>
void iter_get(I s, V& v)
{
v = *s++;
}
template <class I, class V, typename... Args>
void iter_get(I s, V& v, Args& ...args)
{
v = *s++;
iter_get(s, args...);
}
template <class C, typename... Args>
int scatter(int n, const C& c, Args& ...args)
{
if(n < sizeof...(args))
return 0;
iter_get(c.begin(), args...);
return sizeof...(args);
}
template <class C, typename... Args>
int scatter(const C& c, Args& ...args)
{
return scatter(c.GetCount(), c, args...);
}
Usage example:
template <typename... Args>
String Format(const char *fmt, const Args& ...args)
{
return Format(fmt, gather<Vector<Value>>(args...));
}
But I guess this would work even better if containers interface was amended to be more "std" (Vector::Vector(int count), size() synonyme for GetCount), so I guess that needs a bit more work...
Mirek
|
|
|
 |
|
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 01:05:19 CEST 2025
Total time taken to generate the page: 0.01263 seconds
|