summaryrefslogtreecommitdiffstats
path: root/test/utility
diff options
context:
space:
mode:
authorPatrick Williams <patrick@stwcx.xyz>2016-07-20 12:34:24 -0500
committerPatrick Williams <patrick@stwcx.xyz>2016-07-26 14:08:32 -0500
commit0c841a17f53aca94cc4f66943c86169def9e5186 (patch)
treef903489164cead1d1f82c232c3d66c25e199927a /test/utility
parent8aaac21e3f820237d3acbedb45e52ce318fd986a (diff)
downloadsdbusplus-0c841a17f53aca94cc4f66943c86169def9e5186.tar.gz
sdbusplus-0c841a17f53aca94cc4f66943c86169def9e5186.zip
Add array_to_ptr template
C++ template to convert T[] type to T* type. Change-Id: I91c63b5d14b77f82d3deea3772990912dfcd4277 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Diffstat (limited to 'test/utility')
-rw-r--r--test/utility/type_traits.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/utility/type_traits.cpp b/test/utility/type_traits.cpp
new file mode 100644
index 0000000..3a31d06
--- /dev/null
+++ b/test/utility/type_traits.cpp
@@ -0,0 +1,24 @@
+#include <sdbusplus/utility/type_traits.hpp>
+
+int main()
+{
+ using sdbusplus::utility::array_to_ptr_t;
+
+ static_assert(
+ std::is_same<char, array_to_ptr_t<char, char>>::value,
+ "array_to_ptr_t<char, char> != char");
+
+ static_assert(
+ std::is_same<char*, array_to_ptr_t<char, char*>>::value,
+ "array_to_ptr_t<char, char*> != char*");
+
+ static_assert(
+ std::is_same<char*, array_to_ptr_t<char, char[100]>>::value,
+ "array_to_ptr_t<char, char[100]> != char*");
+
+ static_assert(
+ std::is_same<char[100], array_to_ptr_t<int, char[100]>>::value,
+ "array_to_ptr_t<int, char[100]> != char[100]");
+
+ return 0;
+}
OpenPOWER on IntegriCloud