D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6340 - std.conv.to: integer to bool conversion
Summary: std.conv.to: integer to bool conversion
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: Other Windows
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-17 13:33 UTC by Andrej Mitrovic
Modified: 2012-04-05 19:49 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrej Mitrovic 2011-07-17 13:33:59 UTC
import std.conv;

void main()
{
    auto x = to!bool(1);
}

D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\conv.d(100): Error: template std.conv.toImpl(T,S) if (!implicitlyConverts!(S,T) && isSomeString!(T) && isInputRange!(Unqual!(S))
&& isSomeChar!(ElementType!(S))) does not match any function template declaration
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\conv.d(100): Error: template std.conv.toImpl(T,S) if (!implicitlyConverts!(S,T) && isSomeString!(T) && isInputRange!(Unqual!(S))
&& isSomeChar!(ElementType!(S))) cannot deduce template function from argument types !(bool)(int)
D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\conv.d(100): Error: template instance errors instantiating template
testconv.d(10): Error: template instance std.conv.to!(bool).to!(int) error instantiating

-------------

Any special reason why this isn't implemented? Was it deemed unsafe?
Comment 1 Andrej Mitrovic 2012-04-05 19:49:41 UTC
Can just use a cast, conv.to is unnecessary.