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 using from_range with std::vector<>::const_iterator #2926

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

Conversation

burlog
Copy link

@burlog burlog commented Oct 29, 2024

This pull request addresses a compile error occurring when attempting to instantiate std::vector with a constant value type.

The issue arose in catch_generators_range.hpp, where ResultType was defined as a value_type of const_iterator within GeneratorWrapper<ResultType> which is usually const. This caused a conflict with std::vector, which requires its value_type to be non-const.

Copy link

codecov bot commented Oct 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.99%. Comparing base (9c5a4cf) to head (8c69645).

Additional details and impacted files
@@           Coverage Diff           @@
##            devel    #2926   +/-   ##
=======================================
  Coverage   90.99%   90.99%           
=======================================
  Files         198      198           
  Lines        8597     8597           
=======================================
  Hits         7822     7822           
  Misses        775      775           

@horenmar
Copy link
Member

Can you provide a reproducer?

@burlog
Copy link
Author

burlog commented Oct 30, 2024

Hm, I see that const_iterators of the standard containers does not have const qualified value_type, so I don't know if my patch is relevant. On the other hand, removing const from value type here probably does not break anything.

I encounter this when I used yaml-cpp for parsing test cases. Simplyfied example is:

#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators_range.hpp>

#include <yaml-cpp/yaml.h>

auto yaml = YAML::LoadFile("test.yaml");

TEST_CASE("test case") {
    auto value = GENERATE(from_range(yaml));
}

@horenmar
Copy link
Member

Hmmmm, I am pretty sure that's yaml-cpp being wrong, I opened up an issue: jbeder/yaml-cpp#1326

I'll have to think about whether I want to merge a workaround for now or not.

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.

2 participants