March 03, 2022

I tried to use std.conv.parse(args[2]),

import std.stdio;

import std.conv;

 void main(string[] args){

	if (args.length > 1) {
		writeln(broadcastSettingChange(args[1]));
		if (args.length == 2) {
		// TODO: second argument needs parse to uint
			writeln(broadcastSettingChange(args[1], std.conv.parse(args[2])));
		
		}
		
	} else {
	
		writeln(broadcastSettingChange());
	}
	write(args.length > 1);


 }

But I'm getting this error

(21): Error: template `std.conv.parse` cannot deduce function from argument types `!()(string)`
.\..\..\src\phobos\std\conv.d(2263):        Candidates are: `parse(Target, Source, Flag doCount = No.doCount)(ref Source source)`
.\..\..\src\phobos\std\conv.d(2382):                        `parse(Target, Source, Flag doCount = No.doCount)(ref Source s)`
.\..\..\src\phobos\std\conv.d(2804):                        `parse(Target, Source, Flag doCount = No.doCount)(ref Source source, uint radix)`
.\..\..\src\phobos\std\conv.d(2973):                        `parse(Target, Source, Flag doCount = No.doCount)(ref Source s)`
.\..\..\src\phobos\std\conv.d(3084):                        `parse(Target, Source, Flag doCount = No.doCount)(ref Source source)`
.\..\..\src\phobos\std\conv.d(3776):                        `parse(Target, Source, Flag doCount = No.doCount)(ref Source s)`
.\..\..\src\phobos\std\conv.d(3833):                        `parse(Target, Source, Flag doCount = No.doCount)(ref Source s)`
.\..\..\src\phobos\std\conv.d(3918):                        `parse(Target, Source, Flag doCount = No.doCount)(ref Source s)`
.\..\..\src\phobos\std\conv.d(4031):                        `parse(Target, Source, Flag doCount = No.doCount)(ref Source s, dchar lbracket = '[', dchar rbracket = ']', dchar comma = ',')`
.\..\..\src\phobos\std\conv.d(4218):                        `parse(Target, Source, Flag doCount = No.doCount)(ref Source s, dchar lbracket = '[', dchar rbracket = ']', dchar comma = ',')`
.\..\..\src\phobos\std\conv.d(4327):                        `parse(Target, Source, Flag doCount = No.doCount)(ref Source s, dchar lbracket = '[', dchar rbracket = ']', dchar keyval = ':', dchar comma = ',')`
WM_SETTINGCHANGE.d(21):        All possible candidates are marked as `deprecated` or `@disable`
Failed: ["C:\\Users\\Windows10\\Desktop\\dmd2\\windows\\bin\\dmd.exe", "-v", "-o-", "WM_SETTINGCHANGE.d", "-I."]
March 03, 2022

On Thursday, 3 March 2022 at 07:32:24 UTC, BoQsc wrote:

>

I tried to use std.conv.parse(args[2]),
[...]
But I'm getting this error

The code doesn't declare the type to be parsed, use parse!uint(...).

But to!uint seems more appropriate for your code because parse ignores non-number characters after the number, e.g.

void main()
{
    string input = "123abc";
    writeln(parse!uint(input)); // 123
}