|
Boost : |
From: Olaf van der Spek (ml_at_[hidden])
Date: 2021-10-31 10:39:54
Hi,
Why does the overload for boost::string_view not work? The std one works.
Could it be made to work?
#include <boost/algorithm/string.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/utility/string_view.hpp>
#include <iostream>
#include <string_view>
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<char,
std::char_traits<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 = boost::basic_string_view<char,
std::char_traits<char> >]â
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<char,
std::char_traits<char> >::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<charT,
traits>::basic_string_view(const std::__cxx11::basic_string<charT,
traits, Allocator>&) [with Allocator = Allocator; charT = char; traits
= std::char_traits<char>]â
97 | basic_string_view(const std::basic_string<charT,
traits, Allocator>& 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<char,
std::char_traits<char>, Allocator>â 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<charT,
traits>::basic_string_view(const charT*,
boost::basic_string_view<charT, traits>::size_type) [with charT =
char; traits = std::char_traits<char>; boost::basic_string_view<charT,
traits>::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<boost::basic_string_view<char,
std::char_traits<char> >, true>::typâ {aka âconst char*â} to
âboost::basic_string_view<char, std::char_traits<char> >::size_typeâ
{aka âlong unsigned intâ} [-fpermissive]
324 | TrimEnd
| ^~~~~~~
| |
|
boost::range_detail::extract_const_iterator<boost::basic_string_view<char,
std::char_traits<char> >, 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<charT,
traits>::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<charT,
traits>::basic_string_view(const boost::basic_string_view<charT,
traits>&) [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<charT,
traits>::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<std::basic_string_view<char>,
true>::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<std::basic_string_view<char>,
true>::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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk