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

Catch::Generators::from_range cannot be used with C array #2737

Closed
mjerabek opened this issue Aug 24, 2023 · 1 comment
Closed

Catch::Generators::from_range cannot be used with C array #2737

mjerabek opened this issue Aug 24, 2023 · 1 comment
Labels

Comments

@mjerabek
Copy link
Contributor

Describe the bug
Using Catch::Generators::from_range with plain array fails: type 'T *[6]' cannot be used prior to '::' because it has no members. That's because the function is defined with typename ResultType = typename Container::value_type .

I think the simplest solution without ADL/non-ADL begin(c) is to add a direct specialization for arrays.

Expected behavior
... It works.

Reproduction steps
https://godbolt.org/z/6r6Gh4M18

Platform information:
Not relevant.

@mjerabek
Copy link
Contributor Author

I imagine something like this could do:

namespace Catch::Generators {
template <typename T, size_t N>
GeneratorWrapper<T> from_range(T const (&cnt)[N]) {
    return GeneratorWrapper<T>(Catch::Detail::make_unique<IteratorGenerator<T>>(cnt, cnt+N));
}    
}

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

2 participants