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 // UNSUPPORTED: c++03, c++11 10 11 // template<class T> 12 // constexpr T& as-lvalue(T&& t) { // exposition only 13 14 #include <__utility/as_lvalue.h> 15 #include <type_traits> 16 #include <utility> 17 18 constexpr bool test() { 19 // Check glvalue 20 { 21 int lvalue{}; 22 [[maybe_unused]] decltype(auto) check = std::__as_lvalue(lvalue); 23 static_assert(std::is_same<decltype(check), int&>::value, ""); 24 } 25 26 // Check xvalue 27 { 28 int xvalue{}; 29 [[maybe_unused]] decltype(auto) check = std::__as_lvalue(std::move(xvalue)); 30 static_assert(std::is_same<decltype(check), int&>::value, ""); 31 } 32 33 return true; 34 } 35 36 int main(int, char**) { 37 test(); 38 static_assert(test(), ""); 39 40 return 0; 41 } 42