Hi,
Why does the overload for boost::string_view not work? The std one works.
Could it be made to work?
#include
#include
#include
#include <iostream>
#include
int main()
{
boost::trim_copy(boost::string_view()); // error
boost::trim_copy(std::string_view());
}
$ g++ t0.cpp
In file included from /usr/include/boost/algorithm/string.hpp:19,
from t0.cpp:1:
/usr/include/boost/algorithm/string/trim.hpp: In instantiation of
‘SequenceT boost::algorithm::trim_copy_if(const SequenceT&,
PredicateT) [with SequenceT = boost::basic_string_view; PredicateT =
boost::algorithm::detail::is_classifiedF]’:
/usr/include/boost/algorithm/string/trim.hpp:343:49: required from
‘SequenceT boost::algorithm::trim_copy(const SequenceT&, const
std::locale&) [with SequenceT = boost::basic_string_view]’
t0.cpp:10:19: required from here
/usr/include/boost/algorithm/string/trim.hpp:319:20: error: no
matching function for call to ‘boost::basic_string_view::basic_string_view(const char*, const
char*&)’
319 | return SequenceT(
| ^~~~~~~~~~
320 | detail::trim_begin(
| ~~~~~~~~~~~~~~~~~~~
321 | ::boost::begin(Input),
| ~~~~~~~~~~~~~~~~~~~~~~
322 | TrimEnd,
| ~~~~~~~~
323 | IsSpace),
| ~~~~~~~~~
324 | TrimEnd
| ~~~~~~~
325 | );
| ~
In file included from t0.cpp:3:
/usr/include/boost/utility/string_view.hpp:97:9: note: candidate:
‘template<class Allocator> boost::basic_string_view::basic_string_view(const std::__cxx11::basic_string&) [with Allocator = Allocator; charT = char; traits
= std::char_traits<char>]’
97 | basic_string_view(const std::basic_string& str) BOOST_NOEXCEPT
| ^~~~~~~~~~~~~~~~~
/usr/include/boost/utility/string_view.hpp:97:9: note: template
argument deduction/substitution failed:
In file included from /usr/include/boost/algorithm/string.hpp:19,
from t0.cpp:1:
/usr/include/boost/algorithm/string/trim.hpp:319:20: note:
mismatched types ‘const std::__cxx11::basic_string’ and ‘const char*’
319 | return SequenceT(
| ^~~~~~~~~~
320 | detail::trim_begin(
| ~~~~~~~~~~~~~~~~~~~
321 | ::boost::begin(Input),
| ~~~~~~~~~~~~~~~~~~~~~~
322 | TrimEnd,
| ~~~~~~~~
323 | IsSpace),
| ~~~~~~~~~
324 | TrimEnd
| ~~~~~~~
325 | );
| ~
In file included from t0.cpp:3:
/usr/include/boost/utility/string_view.hpp:110:23: note: candidate:
‘constexpr boost::basic_string_view::basic_string_view(const charT*,
boost::basic_string_view::size_type) [with charT =
char; traits = std::char_traits<char>; boost::basic_string_view::size_type = long unsigned int]’ (near match)
110 | BOOST_CONSTEXPR basic_string_view(const charT* str, size_type len)
| ^~~~~~~~~~~~~~~~~
/usr/include/boost/utility/string_view.hpp:110:23: note: conversion
of argument 2 would be ill-formed:
In file included from /usr/include/boost/algorithm/string.hpp:19,
from t0.cpp:1:
/usr/include/boost/algorithm/string/trim.hpp:324:17: error: invalid
conversion from
‘boost::range_detail::extract_const_iterator, true>::typ’ {aka ‘const char*’} to
‘boost::basic_string_view::size_type’
{aka ‘long unsigned int’} [-fpermissive]
324 | TrimEnd
| ^~~~~~~
| |
|
boost::range_detail::extract_const_iterator, true>::type {aka const char*}
In file included from t0.cpp:3:
/usr/include/boost/utility/string_view.hpp:107:23: note: candidate:
‘constexpr boost::basic_string_view::basic_string_view(const charT*) [with charT = char; traits =
std::char_traits<char>]’
107 | BOOST_CONSTEXPR basic_string_view(const charT* str)
| ^~~~~~~~~~~~~~~~~
/usr/include/boost/utility/string_view.hpp:107:23: note: candidate
expects 1 argument, 2 provided
/usr/include/boost/utility/string_view.hpp:78:23: note: candidate:
‘constexpr boost::basic_string_view::basic_string_view(const boost::basic_string_view&) [with charT = char; traits = std::char_traits<char>]’
78 | BOOST_CONSTEXPR basic_string_view(const
basic_string_view &rhs) BOOST_NOEXCEPT
| ^~~~~~~~~~~~~~~~~
/usr/include/boost/utility/string_view.hpp:78:23: note: candidate
expects 1 argument, 2 provided
/usr/include/boost/utility/string_view.hpp:73:23: note: candidate:
‘constexpr boost::basic_string_view::basic_string_view() [with charT = char; traits =
std::char_traits<char>]’
73 | BOOST_CONSTEXPR basic_string_view() BOOST_NOEXCEPT
| ^~~~~~~~~~~~~~~~~
/usr/include/boost/utility/string_view.hpp:73:23: note: candidate
expects 0 arguments, 2 provided
In file included from /usr/include/boost/algorithm/string.hpp:19,
from t0.cpp:1:
/usr/include/boost/algorithm/string/trim.hpp: In instantiation of
‘SequenceT boost::algorithm::trim_copy_if(const SequenceT&,
PredicateT) [with SequenceT = std::basic_string_view<char>; PredicateT
= boost::algorithm::detail::is_classifiedF]’:
/usr/include/boost/algorithm/string/trim.hpp:343:49: required from
‘SequenceT boost::algorithm::trim_copy(const SequenceT&, const
std::locale&) [with SequenceT = std::basic_string_view<char>]’
t0.cpp:11:19: required from here
/usr/include/boost/algorithm/string/trim.hpp:324:17: error: invalid
conversion from
‘boost::range_detail::extract_const_iterator::type’ {aka ‘const char*’} to
‘std::basic_string_view<char>::size_type’ {aka ‘long unsigned int’}
[-fpermissive]
324 | TrimEnd
| ^~~~~~~
| |
|
boost::range_detail::extract_const_iterator::type {aka const char*}
In file included from /usr/include/c++/11/bits/basic_string.h:48,
from /usr/include/c++/11/string:55,
from
/usr/include/boost/algorithm/string/std/string_traits.hpp:15,
from
/usr/include/boost/algorithm/string/std_containers_traits.hpp:19,
from /usr/include/boost/algorithm/string.hpp:18,
from t0.cpp:1:
/usr/include/c++/11/string_view:137:56: note: initializing argument
2 of ‘constexpr std::basic_string_view<_CharT,
_Traits>::basic_string_view(const _CharT*,
std::basic_string_view<_CharT, _Traits>::size_type) [with _CharT =
char; _Traits = std::char_traits<char>; std::basic_string_view<_CharT,
_Traits>::size_type = long unsigned int]’
137 | basic_string_view(const _CharT* __str, size_type __len) noexcept
| ~~~~~~~~~~^~~~~
--
Olaf