[libcxx] r255513 - Add add_lvalue_ref tests for a few function types, with a note why not more
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 14 09:34:04 PST 2015
Author: marshall
Date: Mon Dec 14 11:34:03 2015
New Revision: 255513
URL: http://llvm.org/viewvc/llvm-project?rev=255513&view=rev
Log:
Add add_lvalue_ref tests for a few function types, with a note why not more
Modified:
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp
Modified: libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp?rev=255513&r1=255512&r2=255513&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp Mon Dec 14 11:34:03 2015
@@ -22,6 +22,26 @@ void test_add_lvalue_reference()
#endif
}
+template <class F>
+void test_function0()
+{
+ static_assert((std::is_same<typename std::add_lvalue_reference<F>::type, F&>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::add_lvalue_reference_t<F>, F&>::value), "");
+#endif
+}
+
+template <class F>
+void test_function1()
+{
+ static_assert((std::is_same<typename std::add_lvalue_reference<F>::type, F>::value), "");
+#if _LIBCPP_STD_VER > 11
+ static_assert((std::is_same<std::add_lvalue_reference_t<F>, F>::value), "");
+#endif
+}
+
+struct Foo {};
+
int main()
{
test_add_lvalue_reference<void, void>();
@@ -31,4 +51,20 @@ int main()
test_add_lvalue_reference<const int&, const int&>();
test_add_lvalue_reference<int*, int*&>();
test_add_lvalue_reference<const int*, const int*&>();
+
+// LWG 2101 specifically talks about add_lvalue_reference and functions.
+// The term of art is "a referenceable type", which a cv- or ref-qualified function is not.
+ test_function0<void()>();
+// test_function1<void() const>();
+// test_function1<void() &>();
+// test_function1<void() &&>();
+// test_function1<void() const &>();
+// test_function1<void() const &&>();
+
+ test_function0<void (Foo::*)()>();
+// test_function1<void (Foo::*)() const>();
+// test_function1<void (Foo::*)() &>();
+// test_function1<void (Foo::*)() &&>();
+// test_function1<void (Foo::*)() const &>();
+// test_function1<void (Foo::*)() const &&>();
}
More information about the cfe-commits
mailing list