xref: /llvm-project/libcxx/test/std/utilities/function.objects/logical.operations/logical_or.pass.cpp (revision dc066888bd98c0500ca7b590317dc91ccce0fd38)
15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric 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
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier 
9*dc066888SArthur O'Dwyer // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
10*dc066888SArthur O'Dwyer 
115a83710eSEric Fiselier // <functional>
125a83710eSEric Fiselier 
135a83710eSEric Fiselier // logical_or
145a83710eSEric Fiselier 
155a83710eSEric Fiselier #include <functional>
165a83710eSEric Fiselier #include <type_traits>
175a83710eSEric Fiselier #include <cassert>
185a83710eSEric Fiselier 
190f901c7eSStephan T. Lavavej #include "test_macros.h"
200f901c7eSStephan T. Lavavej 
main(int,char **)212df59c50SJF Bastien int main(int, char**)
225a83710eSEric Fiselier {
235a83710eSEric Fiselier     typedef std::logical_or<int> F;
245a83710eSEric Fiselier     const F f = F();
25*dc066888SArthur O'Dwyer #if TEST_STD_VER <= 17
2666369c03SMarshall Clow     static_assert((std::is_same<int, F::first_argument_type>::value), "" );
2766369c03SMarshall Clow     static_assert((std::is_same<int, F::second_argument_type>::value), "" );
2866369c03SMarshall Clow     static_assert((std::is_same<bool, F::result_type>::value), "" );
29*dc066888SArthur O'Dwyer #endif
305a83710eSEric Fiselier     assert(f(36, 36));
315a83710eSEric Fiselier     assert(f(36, 0));
325a83710eSEric Fiselier     assert(f(0, 36));
335a83710eSEric Fiselier     assert(!f(0, 0));
340f901c7eSStephan T. Lavavej #if TEST_STD_VER > 11
355a83710eSEric Fiselier     typedef std::logical_or<> F2;
365a83710eSEric Fiselier     const F2 f2 = F2();
375a83710eSEric Fiselier     assert( f2(36, 36));
385a83710eSEric Fiselier     assert( f2(36, 36L));
395a83710eSEric Fiselier     assert( f2(36L, 36));
405a83710eSEric Fiselier     assert( f2(36, 0));
415a83710eSEric Fiselier     assert( f2(0, 36));
425a83710eSEric Fiselier     assert( f2(36, 0L));
435a83710eSEric Fiselier     assert( f2(0, 36L));
445a83710eSEric Fiselier     assert(!f2(0, 0));
455a83710eSEric Fiselier     assert(!f2(0, 0L));
465a83710eSEric Fiselier     assert(!f2(0L, 0));
475a83710eSEric Fiselier 
485a83710eSEric Fiselier     constexpr bool foo = std::logical_or<int> () (36, 36);
495a83710eSEric Fiselier     static_assert ( foo, "" );
505a83710eSEric Fiselier 
515a83710eSEric Fiselier     constexpr bool bar = std::logical_or<> () (36.0, 36);
525a83710eSEric Fiselier     static_assert ( bar, "" );
535a83710eSEric Fiselier #endif
542df59c50SJF Bastien 
552df59c50SJF Bastien   return 0;
565a83710eSEric Fiselier }
57