Home » Community » U++ community news and announcements » get_i
Re: get_i [message #54348 is a reply to message #54247] |
Mon, 29 June 2020 19:23   |
 |
mirek
Messages: 14256 Registered: November 2005
|
Ultimate Member |
|
|
I have just found that this fails with Visual C++ compiler:
String n = " 2";
ASSERT(decode(4, 1, "one", 2, "two", 3, "three", "unknown" + n) == String("unknown 2"));
The problem is that temporaty object gets destroyed too early...
I _believe_ this is a compiler error. In any case, it is pretty bad.
EDIT: Not a compiler bug. The problem is in your decode. Fixed it with
template <class T, class V>
constexpr const V& decode(const T& sel, const V& def)
{
return def;
}
template <class T, class K, class V, typename... L>
constexpr const V& decode(const T& sel, const K& k, const V& v, const L& ...args)
{
return sel == k ? v : decode(sel, args...);
}
template <class T>
constexpr const char *decode(const T& sel, const char *def)
{
return def;
}
template <class T, class K, typename... L>
constexpr const char *decode(const T& sel, const K& k, const char *v, const L& ...args)
{
return sel == k ? v : (const char *)decode(sel, args...);
}
[Updated on: Mon, 29 June 2020 23:08] Report message to a moderator
|
|
|
 |
|
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:03:00 CEST 2025
Total time taken to generate the page: 0.04528 seconds
|