1 // Copyright (C) 2019-2021 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library.  This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
7 // any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3.  If not see
16 // <http://www.gnu.org/licenses/>.
17 
18 // { dg-options "-std=gnu++2a" }
19 // { dg-do compile { target c++2a } }
20 
21 #include <functional>
22 
23 #ifndef __cpp_lib_constexpr_functional
24 # error "Feature test macro for constexpr searcher is missing in <functional>"
25 #elif __cpp_lib_constexpr_functional < 201811L
26 # error "Feature test macro for constexpr searcher has wrong value in <functional>"
27 #endif
28 
29 #include <string_view>
30 
31 const std::string_view
32 patt = "World";
33 
34 constexpr std::string_view
35 greet = "Hello, Humongous World of Wonder!!!";
36 
37 const std::wstring_view
38 wpatt = L"World";
39 
40 constexpr std::wstring_view
41 wgreet = L"Hello, Humongous World of Wonder!!!";
42 
43 constexpr bool
test_searcher()44 test_searcher()
45 {
46   auto ok = true;
47 
48   const std::default_searcher search(patt.begin(), patt.end(),
49 				     std::equal_to<>());
50   const auto find = search(greet.begin(), greet.end());
51 
52   const std::default_searcher wsearch(wpatt.begin(), wpatt.end(),
53 				      std::equal_to<>());
54   const auto wfind = wsearch(wgreet.begin(), wgreet.end());
55 
56   return ok;
57 }
58 
59 static_assert(test_searcher());
60