-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Closed as not planned
Closed as not planned
Copy link
Labels
libstdc++GNU libstdc++ C++ standard libraryGNU libstdc++ C++ standard librarylwg-issuethis is an issue that was filed to the Library Working Groupthis is an issue that was filed to the Library Working Group
Description
Attempting to pass a std::ranges::const_iterator_t as a template parameter fails when std::ranges::cbegin is passed to the function.
#include <iterator>
#include <ranges>
#include <string>
template<std::input_iterator IT_T>
void some_function(IT_T)
{
}
int main(void) {
std::string someString;
some_function<std::ranges::const_iterator_t<std::string>>(std::ranges::cbegin(someString));
}causes the compiler to fail with the following output:
<source>:13:4: error: no matching function for call to 'some_function'
13 | some_function<std::ranges::const_iterator_t<std::string>>(std::ranges::cbegin(someString));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:6:6: note: candidate function template not viable: no known conversion from 'const_iterator_t<decltype(__r)>' to 'const_iterator_t<std::string>' for 1st argument
6 | void some_function(IT_T)
| ^ ~~~~
1 error generated.
Compiler returned: 1
note that adding const to the variable and the const_iterator_t type results in the program compiling as expected
#include <iterator>
#include <ranges>
#include <string>
template<std::input_iterator IT_T>
void some_function(IT_T)
{
}
int main(void) {
std::string const someString;
some_function<std::ranges::const_iterator_t<std::string const&>>(std::ranges::cbegin(someString));
}Metadata
Metadata
Assignees
Labels
libstdc++GNU libstdc++ C++ standard libraryGNU libstdc++ C++ standard librarylwg-issuethis is an issue that was filed to the Library Working Groupthis is an issue that was filed to the Library Working Group