That would possibly be function overload resolution at runtime?
(You suggested different function parameter types and overloads for storing into a map.)
It could also possibly lead to failed overload resolution only detected at runtime?
-----Ursprüngliche Nachricht-----
Von: Frederick Virchanza Gotham via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Di 30.04.2024 16:05
Betreff: Re: [std-proposals] Function only accepts parameter that will persist
An: std-proposals@lists.isocpp.org;
CC: Frederick Virchanza Gotham <cauldwell.thomas@gmail.com>;
On Tue, Apr 30, 2024 at 3:01 PM I wrote:
>
> But maybe we need some sort of class that has the option of copying
> the object, something like this:
>
> https://godbolt.org/z/rz6dfvGPo
Just one other thing I want to mention . . . In the following constructor:
String(char const *const arg) noexcept(false)
{
std::cout << "copying\n";
p = new char[ std::strlen(arg) + 1u ];
should_delete = true;
std::strcpy( const_cast<char*>(p), arg );
}
You could check if 'arg' points to a page of memory that is read-only.
If it's read-only then use the non-copying constructor instead. On
MS-Windows, 'VirtualProtect' gives us this info. On Linux, 'mprotect'
give us this info. On a microcontroller, check if the address is in
the range 0x0 - 0x2000 (i.e. read-only ROM), or from 0x2000 onwards
(i.e. volatile RAM).
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals