Hi - I am trying to compile this example I found online. I am able to do this Windows VS 2019 and Debian g++ 8.3 as long as I specify c++17.
Using clang version 10.0.1
Using clang version 10.0.1
Code:
[jon2allen@freebsd12_3 ~/github/c++]$ cat string_search1.cpp
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <string>
#include <string_view>
int main()
{
constexpr std::string_view haystack =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed "
"do eiusmod tempor incididunt ut labore et dolore magna aliqua";
const std::string_view needle{"pisci"};
if (const auto it = std::search(haystack.begin(), haystack.end(),
std::boyer_moore_searcher(needle.begin(), needle.end()));
it != haystack.end()
)
std::cout << "The string " << std::quoted(needle) << " found at offset "
<< it - haystack.begin() << '\n';
else
std::cout << "The string " << std::quoted(needle) << " not found\n";
}
[jon2allen@freebsd12_3 ~/github/c++]$ c++ -std=c++17 string_search1.cpp -o string_search1
string_search1.cpp:17:18: error: no member named 'boyer_moore_searcher' in namespace 'std'
std::boyer_moore_searcher(needle.begin(), needle.end()));
~~~~~^
1 error generated.
You have new mail in /var/mail/jon2allen
[jon2allen@freebsd12_3 ~/github/c++]$ c++ -std=c++20 string_search1.cpp -o string_search1
string_search1.cpp:17:18: error: no member named 'boyer_moore_searcher' in namespace 'std'
std::boyer_moore_searcher(needle.begin(), needle.end()));
~~~~~^
1 error generated.
[jon2allen@freebsd12_3 ~/github/c++]$
[jon2allen@freebsd12_3 ~/github/c++]$ c++ --version
FreeBSD clang version 10.0.1 ([email]git@github.com[/email]:llvm/llvm-project.git llvmorg-10.0.1-0-gef32c611aa2)
Target: x86_64-unknown-freebsd12.3
Thread model: posix
InstalledDir: /usr/bin