www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - std.conv checking if "to" will work

reply "Robert burner Schadek" <rburners gmail.com> writes:
I like the "to" template a lot, but sometimes I want to make sure 
beforehand that a call to it works. Is there anything in phobos 
in missed to do that. And I don't want to try catch.
Sep 11 2014
parent reply "monarch_dodra" <monarchdodra gmail.com> writes:
On Thursday, 11 September 2014 at 08:58:09 UTC, Robert burner 
Schadek wrote:
 I like the "to" template a lot, but sometimes I want to make 
 sure beforehand that a call to it works. Is there anything in 
 phobos in missed to do that. And I don't want to try catch.
There's an open request for it, and plans to have a "bool maybeTo!(OUT, WHAT)(WHAT what, ref OUT out)", but we aren't quite there yet. The idea is that *once* we have that, then "to" would simply become an "enforce!maybeTo". But in the meantime, no. you have to trycatch.
Sep 11 2014
parent reply "Robert burner Schadek" <rburners gmail.com> writes:
On Thursday, 11 September 2014 at 09:10:03 UTC, monarch_dodra 
wrote:

 There's an open request for it, and plans to have a "bool 
 maybeTo!(OUT, WHAT)(WHAT what, ref OUT out)", but we aren't 
 quite there yet.

 The idea is that *once* we have that, then "to" would simply 
 become an "enforce!maybeTo".

 But in the meantime, no. you have to trycatch.
thanks for the quick anwser. Is anyone working on it currently? just for completeness the bugzilla entry is: https://issues.dlang.org/show_bug.cgi?id=6840
Sep 11 2014
parent "monarch_dodra" <monarchdodra gmail.com> writes:
On Thursday, 11 September 2014 at 09:33:20 UTC, Robert burner 
Schadek wrote:
 On Thursday, 11 September 2014 at 09:10:03 UTC, monarch_dodra 
 wrote:

 There's an open request for it, and plans to have a "bool 
 maybeTo!(OUT, WHAT)(WHAT what, ref OUT out)", but we aren't 
 quite there yet.

 The idea is that *once* we have that, then "to" would simply 
 become an "enforce!maybeTo".

 But in the meantime, no. you have to trycatch.
thanks for the quick anwser. Is anyone working on it currently? just for completeness the bugzilla entry is: https://issues.dlang.org/show_bug.cgi?id=6840
Nope, no one (AFAIK). I think it "only" needs a bit of refactoring std.conv, but it's a pretty damn big module.
Sep 11 2014