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 // negate 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 Bastienint main(int, char**) 225a83710eSEric Fiselier { 235a83710eSEric Fiselier typedef std::negate<int> F; 245a83710eSEric Fiselier const F f = F(); 25*dc066888SArthur O'Dwyer #if TEST_STD_VER <= 17 26601fa8d8SMarshall Clow static_assert((std::is_same<F::argument_type, int>::value), "" ); 27601fa8d8SMarshall Clow static_assert((std::is_same<F::result_type, int>::value), "" ); 28*dc066888SArthur O'Dwyer #endif 295a83710eSEric Fiselier assert(f(36) == -36); 300f901c7eSStephan T. Lavavej #if TEST_STD_VER > 11 315a83710eSEric Fiselier typedef std::negate<> F2; 325a83710eSEric Fiselier const F2 f2 = F2(); 335a83710eSEric Fiselier assert(f2(36) == -36); 345a83710eSEric Fiselier assert(f2(36L) == -36); 355a83710eSEric Fiselier assert(f2(36.0) == -36); 365a83710eSEric Fiselier 375a83710eSEric Fiselier constexpr int foo = std::negate<int> () (3); 385a83710eSEric Fiselier static_assert ( foo == -3, "" ); 395a83710eSEric Fiselier 40c255fa5eSStephan T. Lavavej constexpr double bar = std::negate<> () (3.0); 41c255fa5eSStephan T. Lavavej static_assert ( bar == -3.0, "" ); 425a83710eSEric Fiselier #endif 432df59c50SJF Bastien 442df59c50SJF Bastien return 0; 455a83710eSEric Fiselier } 46