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

fix issue with using operator << on argagg types as generics #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mwaltza
Copy link

@mwaltza mwaltza commented Jun 15, 2024

Prior to this change when trying to compile the following sample code:

#include <iostream>

template<typename T>
void logGeneric(T param) {
    std::cout << param << std::endl;
}

#include "include/argagg/argagg.hpp"

int main() {
    argagg::parser argParser{{{"help", {"-h", "--help"}, "Shows this help message.", 0}}};
    logGeneric<argagg::parser>(argParser);
    return 0;
}

I get this:

argagg % g++ --std=c++11 main.cpp 
main.cpp:6:15: error: call to function 'operator<<' that is neither visible in the template definition nor found by argument-dependent lookup
    std::cout << param << std::endl;
              ^
main.cpp:13:5: note: in instantiation of function template specialization 'logGeneric<argagg::parser>' requested here
    logGeneric<argagg::parser>(argParser);
    ^
./include/argagg/argagg.hpp:1692:15: note: 'operator<<' should be declared prior to the call site or in namespace 'argagg'
std::ostream& operator << (std::ostream& os, const argagg::parser& x)
              ^
1 error generated.

This change fixes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant