xref: /llvm-project/libcxx/test/std/utilities/function.objects/comparisons/constexpr_init.pass.cpp (revision 6900df37d26764b828dbc5c2f98a57abbce1583e)
1decf22e5SEric Fiselier //===----------------------------------------------------------------------===//
2decf22e5SEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6decf22e5SEric Fiselier //
7decf22e5SEric Fiselier //===----------------------------------------------------------------------===//
8decf22e5SEric Fiselier 
9*31cbe0f2SLouis Dionne // UNSUPPORTED: c++03, c++11
10decf22e5SEric Fiselier 
11decf22e5SEric Fiselier // <functional>
12decf22e5SEric Fiselier 
13decf22e5SEric Fiselier // equal_to, not_equal_to, less, et al.
14decf22e5SEric Fiselier 
15decf22e5SEric Fiselier // Test that these types can be constructed w/o an initializer in a constexpr
16decf22e5SEric Fiselier // context. This is specifically testing gcc.gnu.org/PR83921
17decf22e5SEric Fiselier 
18decf22e5SEric Fiselier 
19decf22e5SEric Fiselier #include <functional>
20decf22e5SEric Fiselier #include "test_macros.h"
21decf22e5SEric Fiselier 
22decf22e5SEric Fiselier template <class T>
test_constexpr_context()23decf22e5SEric Fiselier constexpr bool test_constexpr_context() {
24decf22e5SEric Fiselier   std::equal_to<T> eq;
25decf22e5SEric Fiselier   ((void)eq);
26decf22e5SEric Fiselier   std::not_equal_to<T> neq;
27decf22e5SEric Fiselier   ((void)neq);
28decf22e5SEric Fiselier   std::less<T> l;
29decf22e5SEric Fiselier   ((void)l);
30decf22e5SEric Fiselier   std::less_equal<T> le;
31decf22e5SEric Fiselier   ((void)le);
32decf22e5SEric Fiselier   std::greater<T> g;
33decf22e5SEric Fiselier   ((void)g);
34decf22e5SEric Fiselier   std::greater_equal<T> ge;
35decf22e5SEric Fiselier   ((void)ge);
36decf22e5SEric Fiselier   return true;
37decf22e5SEric Fiselier }
38decf22e5SEric Fiselier 
39decf22e5SEric Fiselier static_assert(test_constexpr_context<int>(), "");
40decf22e5SEric Fiselier static_assert(test_constexpr_context<void>(), "");
41decf22e5SEric Fiselier 
42decf22e5SEric Fiselier 
main(int,char **)432df59c50SJF Bastien int main(int, char**) {
44decf22e5SEric Fiselier 
452df59c50SJF Bastien 
462df59c50SJF Bastien   return 0;
47decf22e5SEric Fiselier }
48