(Go: >> BACK << -|- >> HOME <<)

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse(): no known conversion from 'clipp::parameter' to 'const clipp::group' for 'cli' #32

Closed
ghost opened this issue Aug 8, 2019 · 2 comments
Labels

Comments

@ghost
Copy link
ghost commented Aug 8, 2019

I cannot compile a simple example. Am I doing anything wrong?

clipp 2c32b2f
clang version 8.0.1 (tags/RELEASE_801/final 366581)
g++ (SUSE Linux) 9.1.1 20190723 [gcc-9-branch revision 273734]

% cat main.cpp
#include <iostream>
#include "clipp.h"
int main(int argc, char** argv)
{
        using namespace clipp;
        bool help = false;
        auto cli = (option("-h").set(help));
        parse(argc, argv, cli);
        return 0;
}
% clang++ main.cpp
main.cpp:8:2: error: no matching function for call to 'parse'
        parse(argc, argv, cli);
        ^~~~~
./clipp.h:5325:1: note: candidate function not viable: no known conversion from 'clipp::parameter' to
      'const clipp::group' for 3rd argument
parse(const int argc, char* argv[], const group& cli, arg_index offset = 1)
^
./clipp.h:5313:1: note: candidate template ignored: deduced conflicting types for parameter 'InputIterator'
      ('int' vs. 'char **')
parse(InputIterator first, InputIterator last, const group& cli)
^
./clipp.h:5281:1: note: candidate function not viable: requires 2 arguments, but 3 were provided
parse(arg_list args, const group& cli)
^
./clipp.h:5294:1: note: candidate function not viable: requires 2 arguments, but 3 were provided
parse(std::initializer_list<const char*> arglist, const group& cli)
^
1 error generated.
% g++ main.cpp                                                                        :(
main.cpp: In function ‘int main(int, char**)’:
main.cpp:8:23: error: no matching function for call to ‘parse(int&, char**&, clipp::parameter&)’
    8 |  parse(argc, argv, cli);
      |                       ^
In file included from main.cpp:2:
clipp.h:5281:1: note: candidate: ‘clipp::parsing_result clipp::parse(clipp::arg_list, const clipp::group&)’
 5281 | parse(arg_list args, const group& cli)
      | ^~~~~
clipp.h:5281:1: note:   candidate expects 2 arguments, 3 provided
clipp.h:5294:1: note: candidate: ‘clipp::parsing_result clipp::parse(std::initializer_list<const char*>, const clipp::group&)’
 5294 | parse(std::initializer_list<const char*> arglist, const group& cli)
      | ^~~~~
clipp.h:5294:1: note:   candidate expects 2 arguments, 3 provided
clipp.h:5313:1: note: candidate: ‘template<class InputIterator> clipp::parsing_result clipp::parse(InputIterator, InputIterator, const clipp::group&)’
 5313 | parse(InputIterator first, InputIterator last, const group& cli)
      | ^~~~~
clipp.h:5313:1: note:   template argument deduction/substitution failed:
main.cpp:8:23: note:   deduced conflicting types for parameter ‘InputIterator’ (‘int’ and ‘char**’)
    8 |  parse(argc, argv, cli);
      |                       ^
In file included from main.cpp:2:
clipp.h:5325:1: note: candidate: ‘clipp::parsing_result clipp::parse(int, char**, const clipp::group&, clipp::arg_index)’
 5325 | parse(const int argc, char* argv[], const group& cli, arg_index offset = 1)
      | ^~~~~
clipp.h:5325:50: note:   no known conversion for argument 3 from ‘clipp::parameter’ to ‘const clipp::group&’
 5325 | parse(const int argc, char* argv[], const group& cli, arg_index offset = 1)
      |                                     ~~~~~~~~~~~~~^~~
@muellan
Copy link
Owner
muellan commented Aug 8, 2019

It doesn't work, because parse expects a clipp::group as third parameter.
This means, you eihter have to add at least one more option, which will generate a group:

auto cli = (option("-h").set(help), option("-x"));

or explicitly make a group:

auto cli = group( option("-h").set(help) );

I should probably add an overload for parse that also accepts a single parameter.

@ghost
Copy link
Author
ghost commented Aug 8, 2019

Thank you.

@ghost ghost closed this as completed Aug 8, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant