15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
35a83710eSEric Fiselier //                     The LLVM Compiler Infrastructure
45a83710eSEric Fiselier //
55a83710eSEric Fiselier // This file is dual licensed under the MIT and the University of Illinois Open
65a83710eSEric Fiselier // Source Licenses. See LICENSE.TXT for details.
75a83710eSEric Fiselier //
85a83710eSEric Fiselier //===----------------------------------------------------------------------===//
95a83710eSEric Fiselier 
105a83710eSEric Fiselier // <functional>
115a83710eSEric Fiselier 
125a83710eSEric Fiselier // divides
135a83710eSEric Fiselier 
145a83710eSEric Fiselier #include <functional>
155a83710eSEric Fiselier #include <type_traits>
165a83710eSEric Fiselier #include <cassert>
175a83710eSEric Fiselier 
180f901c7eSStephan T. Lavavej #include "test_macros.h"
190f901c7eSStephan T. Lavavej 
205a83710eSEric Fiselier int main()
215a83710eSEric Fiselier {
225a83710eSEric Fiselier     typedef std::divides<int> F;
235a83710eSEric Fiselier     const F f = F();
2466369c03SMarshall Clow     static_assert((std::is_same<int, F::first_argument_type>::value), "" );
2566369c03SMarshall Clow     static_assert((std::is_same<int, F::second_argument_type>::value), "" );
2666369c03SMarshall Clow     static_assert((std::is_same<int, F::result_type>::value), "" );
275a83710eSEric Fiselier     assert(f(36, 4) == 9);
280f901c7eSStephan T. Lavavej #if TEST_STD_VER > 11
295a83710eSEric Fiselier     typedef std::divides<> F2;
305a83710eSEric Fiselier     const F2 f2 = F2();
315a83710eSEric Fiselier     assert(f2(36, 4) == 9);
325a83710eSEric Fiselier     assert(f2(36.0, 4) == 9);
335a83710eSEric Fiselier     assert(f2(18, 4.0) == 4.5); // exact in binary
345a83710eSEric Fiselier 
355a83710eSEric Fiselier     constexpr int foo = std::divides<int> () (3, 2);
365a83710eSEric Fiselier     static_assert ( foo == 1, "" );
375a83710eSEric Fiselier 
38*c255fa5eSStephan T. Lavavej     constexpr double bar = std::divides<> () (3.0, 2);
39*c255fa5eSStephan T. Lavavej     static_assert ( bar == 1.5, "" ); // exact in binary
405a83710eSEric Fiselier #endif
415a83710eSEric Fiselier }
42