www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Why both isSafe and isUnsafe?

reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
https://dlang.org/phobos/std_traits.html#isSafe
https://dlang.org/phobos/std_traits.html#isUnsafe

Implementation:

template isUnsafe(alias func)
{
     enum isUnsafe = !isSafe!func;
}

Why do we need both?
Sep 27 2020
parent Steven Schveighoffer <schveiguy gmail.com> writes:
On 9/27/20 11:00 PM, Andrei Alexandrescu wrote:
 https://dlang.org/phobos/std_traits.html#isSafe
 https://dlang.org/phobos/std_traits.html#isUnsafe
 
 Implementation:
 
 template isUnsafe(alias func)
 {
      enum isUnsafe = !isSafe!func;
 }
 
 Why do we need both?
They were both added in one PR. 10 years ago. Probably don't need both. But just undocument the second, and leave it. It's not a harm to leave it in and then it won't break code. Can also now be shrunk to a short form: enum isUnsafe(alias func) = !isSafe!func; -Steve
Sep 27 2020