Question Details

No question body available.

Tags

c++ c++20 std-ranges

Answers (1)

January 8, 2026 Score: 0 Rep: 447 Quality: Low Completeness: 50%

You can add a negative constraint to your requires clause to explicitly exclude std::vector from the range specialization. This forces it to fall back to the primary template.

#include 
#include 
#include 

template class Exporter { public: void print(T const& value) { } };

template requires (!std::same_as) class Exporter { public: void print(R& value) { Exporter exporter; for (auto&& item : value) { exporter.print(item); } } };