| 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 | // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS |
| 10 | |
| 11 | // <functional> |
| 12 | |
| 13 | // multiplies |
| 14 | |
| 15 | #include <functional> |
| 16 | #include <type_traits> |
| 17 | #include <cassert> |
| 18 | |
| 19 | #include "test_macros.h" |
| 20 | |
| 21 | int main(int, char**) |
| 22 | { |
| 23 | typedef std::multiplies<int> F; |
| 24 | const F f = F(); |
| 25 | #if TEST_STD_VER <= 17 |
| 26 | static_assert((std::is_same<int, F::first_argument_type>::value), "" ); |
| 27 | static_assert((std::is_same<int, F::second_argument_type>::value), "" ); |
| 28 | static_assert((std::is_same<int, F::result_type>::value), "" ); |
| 29 | #endif |
| 30 | assert(f(3, 2) == 6); |
| 31 | #if TEST_STD_VER > 11 |
| 32 | typedef std::multiplies<> F2; |
| 33 | const F2 f2 = F2(); |
| 34 | assert(f2(3,2) == 6); |
| 35 | assert(f2(3.0, 2) == 6); |
| 36 | assert(f2(3, 2.5) == 7.5); // exact in binary |
| 37 | |
| 38 | constexpr int foo = std::multiplies<int> () (3, 2); |
| 39 | static_assert ( foo == 6, "" ); |
| 40 | |
| 41 | constexpr double bar = std::multiplies<> () (3.0, 2); |
| 42 | static_assert ( bar == 6.0, "" ); |
| 43 | #endif |
| 44 | |
| 45 | return 0; |
| 46 | } |
| 47 | |