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 
95a83710eSEric Fiselier // <functional>
105a83710eSEric Fiselier 
115a83710eSEric Fiselier // placeholders
1255533071SEric Fiselier // The placeholders are constexpr in C++17 and beyond.
1355533071SEric Fiselier // libc++ provides constexpr placeholders in C++11 and beyond.
145a83710eSEric Fiselier 
155a83710eSEric Fiselier #include <functional>
16c281a7a1SEric Fiselier #include <type_traits>
175a83710eSEric Fiselier 
1855533071SEric Fiselier #include "test_macros.h"
1955533071SEric Fiselier 
205a83710eSEric Fiselier template <class T>
215a83710eSEric Fiselier void
test(const T & t)225a83710eSEric Fiselier test(const T& t)
235a83710eSEric Fiselier {
24c281a7a1SEric Fiselier     // Test default constructible.
255a83710eSEric Fiselier     T t2;
26c281a7a1SEric Fiselier     ((void)t2);
27c281a7a1SEric Fiselier     // Test copy constructible.
285a83710eSEric Fiselier     T t3 = t;
29c281a7a1SEric Fiselier     ((void)t3);
30c281a7a1SEric Fiselier     static_assert(std::is_nothrow_copy_constructible<T>::value, "");
31c281a7a1SEric Fiselier     static_assert(std::is_nothrow_move_constructible<T>::value, "");
325a83710eSEric Fiselier }
335a83710eSEric Fiselier 
3455533071SEric Fiselier #if TEST_STD_VER >= 11
3555533071SEric Fiselier constexpr decltype(std::placeholders::_1)  default1{};
3655533071SEric Fiselier constexpr decltype(std::placeholders::_2)  default2{};
3755533071SEric Fiselier constexpr decltype(std::placeholders::_3)  default3{};
3855533071SEric Fiselier constexpr decltype(std::placeholders::_4)  default4{};
3955533071SEric Fiselier constexpr decltype(std::placeholders::_5)  default5{};
4055533071SEric Fiselier constexpr decltype(std::placeholders::_6)  default6{};
4155533071SEric Fiselier constexpr decltype(std::placeholders::_7)  default7{};
4255533071SEric Fiselier constexpr decltype(std::placeholders::_8)  default8{};
4355533071SEric Fiselier constexpr decltype(std::placeholders::_9)  default9{};
4455533071SEric Fiselier constexpr decltype(std::placeholders::_10) default10{};
4555533071SEric Fiselier 
4655533071SEric Fiselier constexpr decltype(std::placeholders::_1)  cp1 = std::placeholders::_1;
4755533071SEric Fiselier constexpr decltype(std::placeholders::_2)  cp2 = std::placeholders::_2;
4855533071SEric Fiselier constexpr decltype(std::placeholders::_3)  cp3 = std::placeholders::_3;
4955533071SEric Fiselier constexpr decltype(std::placeholders::_4)  cp4 = std::placeholders::_4;
5055533071SEric Fiselier constexpr decltype(std::placeholders::_5)  cp5 = std::placeholders::_5;
5155533071SEric Fiselier constexpr decltype(std::placeholders::_6)  cp6 = std::placeholders::_6;
5255533071SEric Fiselier constexpr decltype(std::placeholders::_7)  cp7 = std::placeholders::_7;
5355533071SEric Fiselier constexpr decltype(std::placeholders::_8)  cp8 = std::placeholders::_8;
5455533071SEric Fiselier constexpr decltype(std::placeholders::_9)  cp9 = std::placeholders::_9;
5555533071SEric Fiselier constexpr decltype(std::placeholders::_10) cp10 = std::placeholders::_10;
5655533071SEric Fiselier #endif // TEST_STD_VER >= 11
5755533071SEric Fiselier 
use_placeholders_to_prevent_unused_warning()58fd838227SEric Fiselier void use_placeholders_to_prevent_unused_warning() {
593777a33dSEric Fiselier #if TEST_STD_VER >= 11
60fd838227SEric Fiselier   ((void)cp1);
61fd838227SEric Fiselier   ((void)cp2);
62fd838227SEric Fiselier   ((void)cp3);
63fd838227SEric Fiselier   ((void)cp4);
64fd838227SEric Fiselier   ((void)cp5);
65fd838227SEric Fiselier   ((void)cp6);
66fd838227SEric Fiselier   ((void)cp7);
67fd838227SEric Fiselier   ((void)cp8);
68fd838227SEric Fiselier   ((void)cp9);
69fd838227SEric Fiselier   ((void)cp10);
70fd838227SEric Fiselier   ((void)default1);
71fd838227SEric Fiselier   ((void)default2);
72fd838227SEric Fiselier   ((void)default3);
73fd838227SEric Fiselier   ((void)default4);
74fd838227SEric Fiselier   ((void)default5);
75fd838227SEric Fiselier   ((void)default6);
76fd838227SEric Fiselier   ((void)default7);
77fd838227SEric Fiselier   ((void)default8);
78fd838227SEric Fiselier   ((void)default9);
79fd838227SEric Fiselier   ((void)default10);
803777a33dSEric Fiselier #endif
81fd838227SEric Fiselier }
82fd838227SEric Fiselier 
main(int,char **)83*2df59c50SJF Bastien int main(int, char**)
845a83710eSEric Fiselier {
85fd838227SEric Fiselier     use_placeholders_to_prevent_unused_warning();
865a83710eSEric Fiselier     test(std::placeholders::_1);
875a83710eSEric Fiselier     test(std::placeholders::_2);
885a83710eSEric Fiselier     test(std::placeholders::_3);
895a83710eSEric Fiselier     test(std::placeholders::_4);
905a83710eSEric Fiselier     test(std::placeholders::_5);
915a83710eSEric Fiselier     test(std::placeholders::_6);
925a83710eSEric Fiselier     test(std::placeholders::_7);
935a83710eSEric Fiselier     test(std::placeholders::_8);
945a83710eSEric Fiselier     test(std::placeholders::_9);
955a83710eSEric Fiselier     test(std::placeholders::_10);
96*2df59c50SJF Bastien 
97*2df59c50SJF Bastien   return 0;
985a83710eSEric Fiselier }
99