diff options
author | Patrick Williams <iawillia@us.ibm.com> | 2015-11-04 08:09:24 -0600 |
---|---|---|
committer | Patrick Williams <iawillia@us.ibm.com> | 2015-12-11 15:30:27 -0600 |
commit | edb283c78cad6294def01f3a8c77cd79db3f81db (patch) | |
tree | 6fcdeb2af6c59960dc54dc30ab31b28b8f87e7c3 /src | |
parent | 2b399b960c2299e851d2ba208f486efed24074c8 (diff) | |
download | talos-hostboot-edb283c78cad6294def01f3a8c77cd79db3f81db.tar.gz talos-hostboot-edb283c78cad6294def01f3a8c77cd79db3f81db.zip |
Implement std::is_integral.
RTC: 124148
Change-Id: I01b8f3c1fb27068e0384045c65c271baefd25622
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/21796
Tested-by: Jenkins Server
Reviewed-by: STEPHEN M. CPREK <smcprek@us.ibm.com>
Reviewed-by: Brian Silver <bsilver@us.ibm.com>
Reviewed-by: Richard J. Knight <rjknight@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/include/type_traits | 2 | ||||
-rw-r--r-- | src/include/util/impl/is_integral.H | 52 | ||||
-rw-r--r-- | src/include/util/impl/type_remove.H | 57 | ||||
-rw-r--r-- | src/usr/testcore/lib/is_integral.H | 70 |
4 files changed, 181 insertions, 0 deletions
diff --git a/src/include/type_traits b/src/include/type_traits index 2e29907b3..14ff5105d 100644 --- a/src/include/type_traits +++ b/src/include/type_traits @@ -23,6 +23,8 @@ /* */ /* IBM_PROLOG_END_TAG */ #include <util/impl/integral.H> +#include <util/impl/type_remove.H> #include <util/impl/is_same.H> +#include <util/impl/is_integral.H> /* vim: set filetype=cpp : */ diff --git a/src/include/util/impl/is_integral.H b/src/include/util/impl/is_integral.H new file mode 100644 index 000000000..0305ee9d5 --- /dev/null +++ b/src/include/util/impl/is_integral.H @@ -0,0 +1,52 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/util/impl/_is_integral.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +#ifndef __UTIL_IMPL_IS_INTEGRAL_H +#define __UTIL_IMPL_IS_INTEGRAL_H + +#include <util/impl/integral.H> +#include <util/impl/type_remove.H> + +namespace std +{ + template <typename T> struct _is_integral : std::false_type {}; + template <> struct _is_integral<bool> : std::true_type {}; + template <> struct _is_integral<char> : std::true_type {}; + template <> struct _is_integral<short> : std::true_type {}; + template <> struct _is_integral<int> : std::true_type {}; + template <> struct _is_integral<long> : std::true_type {}; + template <> struct _is_integral<long long> : std::true_type {}; + template <> struct _is_integral<unsigned char> : std::true_type {}; + template <> struct _is_integral<unsigned short> : std::true_type {}; + template <> struct _is_integral<unsigned int> : std::true_type {}; + template <> struct _is_integral<unsigned long> : std::true_type {}; + template <> struct _is_integral<unsigned long long> : std::true_type {}; + + template <typename T> struct is_integral : + _is_integral< + typename std::remove_cv< + typename std::remove_reference<T>::type>::type> {}; + +} +#endif diff --git a/src/include/util/impl/type_remove.H b/src/include/util/impl/type_remove.H new file mode 100644 index 000000000..4b33f2e36 --- /dev/null +++ b/src/include/util/impl/type_remove.H @@ -0,0 +1,57 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/util/impl/type_remove.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +#ifndef __UTIL_IMPL_TYPE_REMOVE_H +#define __UTIL_IMPL_TYPE_REMOVE_H + +namespace std +{ + template <typename T> struct remove_const { typedef T type; }; + template <typename T> struct remove_const<const T> { typedef T type; }; + + template <typename T> struct remove_volatile { typedef T type; }; + template <typename T> struct remove_volatile<volatile T> + { typedef T type; }; + + template <typename T> struct remove_cv + { + typedef typename remove_const<typename remove_volatile<T>::type>::type + type; + }; + + template <typename T> struct remove_reference { typedef T type; }; + template <typename T> struct remove_reference<T&> { typedef T type; }; + template <typename T> struct remove_reference<T&&> { typedef T type; }; + + template <typename T> struct remove_pointer { typedef T type; }; + template <typename T> struct remove_pointer<T*> { typedef T type; }; + template <typename T> struct remove_pointer<T* const> { typedef T type; }; + template <typename T> struct remove_pointer<T* volatile> + { typedef T type; }; + template <typename T> struct remove_pointer<T* const volatile> + { typedef T type; }; + +} + +#endif diff --git a/src/usr/testcore/lib/is_integral.H b/src/usr/testcore/lib/is_integral.H new file mode 100644 index 000000000..250df9552 --- /dev/null +++ b/src/usr/testcore/lib/is_integral.H @@ -0,0 +1,70 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/testcore/lib/is_integral.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2015 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +#ifndef __LIB_IS_INTEGRAL_H +#define __LIB_IS_INTEGRAL_H + +#include <cxxtest/TestSuite.H> +#include <type_traits> + +class STLIsIntegralTest : public CxxTest::TestSuite +{ + public: + void testIsIntegral() + { + using namespace std; + + if(!is_integral<bool>::value) + { + TS_FAIL("is_integral<bool> is false."); + } + if(!is_integral<const bool>::value) + { + TS_FAIL("is_integral<const bool> is false."); + } + if(!is_integral<bool&>::value) + { + TS_FAIL("is_integral<bool&> is false."); + } + if(!is_integral<int>::value) + { + TS_FAIL("is_integral<int> is false."); + } + if(!is_integral<unsigned int>::value) + { + TS_FAIL("is_integral<unsigned int> is false."); + } + if(is_integral<float>::value) + { + TS_FAIL("is_integral<float> is true."); + } + if(is_integral<char*>::value) + { + TS_FAIL("is_integral<char*> is true."); + } + } + +}; + +#endif |