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

Failed to specialize function template #127

Open
Browby opened this issue Sep 27, 2024 · 0 comments
Open

Failed to specialize function template #127

Browby opened this issue Sep 27, 2024 · 0 comments

Comments

@Browby
Copy link

Browby commented Sep 27, 2024

Hi,

I have been trying to use this library within a simple visual studio project.
This works without issues:

#include <iostream>
#include "scn/scan.h"

int main () {
    if (auto result = scn::scan<int, double>("12, 3.1415", "{} {}"); result) {
        const auto& [first, second] = result->values();
        std::cout << first << " " << second << "\n";
    }
}

However, if I add the required code for a custom type.

struct Test {
    int i;
};

template<>
struct scn::scanner<Test> : scn::scanner<int> {
    template<typename Context>
    auto scan(Test& test, Context& ctx) -> scn::scan_expected<typename Context::Iterator> {
        return scn::scanner<int>{}.scan(test.i, ctx);
    }
};

int main() {
    auto result = scn::scan<Test>("12", "{}");
    std::cout << result->value() << "\n";
}

I get the following compiler error C2672 'scn::v3::scanner<Test,char,void>::scan': no matching overloaded function found.

1><path>\scnlib\include\scn\scan.h(4942,9): error C2672: 'scn::v3::scanner<Test,char,void>::scan': no matching overloaded function found
1>could be 'scn::v3::scan_expected<Context::Iterator> scn::v3::scanner<Test,char,void>::scan(Test &,Context &)'
1>	<path>\scnlib\include\scn\scan.h(4942,9):
1>	Failed to specialize function template 'scn::v3::scan_expected<Context::Iterator> scn::v3::scanner<Test,char,void>::scan(Test &,Context &)'
1>		<path>\scnlib\include\scn\scan.h(4942,9):
1>		With the following template arguments:
1>			<path>\scnlib\include\scn\scan.h(4942,9):
1>			'Context=context_type'

I'm using the latest 3.0.1 together with visual studio 2022 17.8.
What am I missing here?

Thanks in advance

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

No branches or pull requests

1 participant