why doesn't "namespace str" insulate me from stuff in algo.h?

Jonathan Wakely jwakely.gcc@gmail.com
Wed Apr 20 10:01:00 GMT 2016

On 20 April 2016 at 05:49, Jim Michaels wrote:
> please invent regex for fstream.

I have no idea what t hat's supposed to mean.

> or find some way to tie them together
> without using std::string or a statically allocated char array.
> ..\..\..\lib\strfuncs\strfuncs.cpp:377:12: note: candidate: size_t
> str::find(STRTYPE, STRTYPE, bool, size_t)
>      size_t find(STRTYPE searchIn, STRTYPE searchFor, bool iCase=false,
> size_t pos=0) {
>             ^~~~
> this error message "note:candidate" has no context. what does it mean?

It should have had context when the compiler printed it, but you've removed it.

When you write a call to 'find' which can't be resolved by the
compiler it prints out the candidate functions that it tried to call
and tells you why it couldn't. In this case it couldn't call std::find
because  you tried to pass a std::u16string in place of a std::string

> ..\..\..\lib\strfuncs\strfuncs.cpp:377:12: note:   no known conversion for
> argument 1 from 'std::__cxx11::u16string {aka
> std::__cxx11::basic_string<char16_t>}' to 'STRTYPE {aka
> std::__cxx11::basic_string<char>}'

> In file included from
> c:\gcc-6-win32\include\c++\6.0.0\bits\locale_facets.h:48:0,
>                  from c:\gcc-6-win32\include\c++\6.0.0\bits\basic_ios.h:37,
>                  from c:\gcc-6-win32\include\c++\6.0.0\ios:44,
>                  from c:\gcc-6-win32\include\c++\6.0.0\ostream:38,
>                  from c:\gcc-6-win32\include\c++\6.0.0\iostream:39,
>                  from ..\..\..\lib\strfuncs\strfuncs.cpp:15:
> c:\gcc-6-win32\include\c++\6.0.0\bits\streambuf_iterator.h:369:5: note:
> candidate: template<class _CharT2> typename
> __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value,
> std::istreambuf_iterator<_CharT> >::__type
> std::find(std::istreambuf_iterator<_CharT>,
> std::istreambuf_iterator<_CharT>, const _CharT2&)
>      find(istreambuf_iterator<_CharT> __first,
>      ^~~~
> what is this saying? and having problems with <algorithm> and <iterator>.

This is another candidate function, and overload called 'find' defined
in namespace std. It's a candidate because you're using arguments of
types defined in namespace std and so Argument Dependent Lookup
applies, see http://en.cppreference.com/w/cpp/language/adl

If you don't want ADL to happen then you nede to call str::find(...)
not just find(...).

More information about the Gcc-help mailing list