1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <functional>
10 
11 // divides
12 
13 #include <functional>
14 #include <type_traits>
15 #include <cassert>
16 
17 #include "test_macros.h"
18 
main(int,char **)19 int main(int, char**)
20 {
21     typedef std::divides<int> F;
22     const F f = F();
23     static_assert((std::is_same<int, F::first_argument_type>::value), "" );
24     static_assert((std::is_same<int, F::second_argument_type>::value), "" );
25     static_assert((std::is_same<int, F::result_type>::value), "" );
26     assert(f(36, 4) == 9);
27 #if TEST_STD_VER > 11
28     typedef std::divides<> F2;
29     const F2 f2 = F2();
30     assert(f2(36, 4) == 9);
31     assert(f2(36.0, 4) == 9);
32     assert(f2(18, 4.0) == 4.5); // exact in binary
33 
34     constexpr int foo = std::divides<int> () (3, 2);
35     static_assert ( foo == 1, "" );
36 
37     constexpr double bar = std::divides<> () (3.0, 2);
38     static_assert ( bar == 1.5, "" ); // exact in binary
39 #endif
40 
41   return 0;
42 }
43