diff --git a/doc/history.qbk b/doc/history.qbk index 8e09205..54c3d09 100644 --- a/doc/history.qbk +++ b/doc/history.qbk @@ -7,6 +7,10 @@ [section:history History] +[h4 Boost-1.70.0] + +* Added new traits __is_bounded_array, __is_unbounded_array. + [h4 Boost-1.68.0] * Added support for detecting trivial moves on clang. diff --git a/doc/is_bounded_array.qbk b/doc/is_bounded_array.qbk new file mode 100644 index 0000000..b114f7f --- /dev/null +++ b/doc/is_bounded_array.qbk @@ -0,0 +1,34 @@ +[/ +Copyright 2018 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, +Version 1.0. (See accompanying file LICENSE_1_0.txt +or copy at http://www.boost.org/LICENSE_1_0.txt). +] + +[section:is_bounded_array is_bounded_array] + + template + struct is_bounded_array + : __tof { }; + +__inherit If T is a (possibly cv-qualified) array type of known bound, then +inherits from __true_type, otherwise inherits from __false_type. + +__header `#include ` + +[all_compilers] + +__examples + +[:`is_bounded_array` inherits from `__true_type`.] + +[:`is_bounded_array::type` is the type `__true_type`.] + +[:`is_bounded_array::value` is an integral constant expression that +evaluates to /true/.] + +[:`is_bounded_array::value_type` is the type `bool`.] + +[endsect] diff --git a/doc/is_unbounded_array.qbk b/doc/is_unbounded_array.qbk new file mode 100644 index 0000000..fc56fe6 --- /dev/null +++ b/doc/is_unbounded_array.qbk @@ -0,0 +1,34 @@ +[/ +Copyright 2018 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, +Version 1.0. (See accompanying file LICENSE_1_0.txt +or copy at http://www.boost.org/LICENSE_1_0.txt). +] + +[section:is_unbounded_array is_unbounded_array] + + template + struct is_unbounded_array + : __tof { }; + +__inherit If T is a (possibly cv-qualified) array type of unknown bound, then +inherits from __true_type, otherwise inherits from __false_type. + +__header `#include ` + +[all_compilers] + +__examples + +[:`is_unbounded_array` inherits from `__true_type`.] + +[:`is_unbounded_array::type` is the type `__true_type`.] + +[:`is_unbounded_array::value` is an integral constant expression that +evaluates to /true/.] + +[:`is_unbounded_array::value_type` is the type `bool`.] + +[endsect] diff --git a/doc/type_traits.qbk b/doc/type_traits.qbk index abc2da2..8d3aaed 100644 --- a/doc/type_traits.qbk +++ b/doc/type_traits.qbk @@ -51,6 +51,8 @@ [def __is_rvalue_reference [link boost_typetraits.reference.is_rvalue_reference is_rvalue_reference]] [def __is_member_pointer [link boost_typetraits.reference.is_member_pointer is_member_pointer]] [def __is_array [link boost_typetraits.reference.is_array is_array]] +[def __is_bounded_array [link boost_typetraits.reference.is_bounded_array is_bounded_array]] +[def __is_unbounded_array [link boost_typetraits.reference.is_unbounded_array is_unbounded_array]] [def __is_union [link boost_typetraits.reference.is_union is_union]] [def __is_class [link boost_typetraits.reference.is_class is_class]] [def __is_enum [link boost_typetraits.reference.is_enum is_enum]] @@ -385,6 +387,7 @@ See __has_trivial_constructor. [include is_array.qbk] [include is_assignable.qbk] [include is_base_of.qbk] +[include is_bounded_array.qbk] [include is_class.qbk] [include is_complete.qbk] [include is_complex.qbk] @@ -424,6 +427,7 @@ See __has_trivial_constructor. [include is_scalar.qbk] [include is_signed.qbk] [include is_stateless.qbk] +[include is_unbounded_array.qbk] [include is_union.qbk] [include is_unsigned.qbk] [include is_virtual_base_of.qbk] diff --git a/include/boost/type_traits/is_bounded_array.hpp b/include/boost/type_traits/is_bounded_array.hpp new file mode 100644 index 0000000..5aeca6f --- /dev/null +++ b/include/boost/type_traits/is_bounded_array.hpp @@ -0,0 +1,42 @@ +/* +Copyright 2018 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, +Version 1.0. (See accompanying file LICENSE_1_0.txt +or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +#ifndef BOOST_TT_IS_BOUNDED_ARRAY_HPP_INCLUDED +#define BOOST_TT_IS_BOUNDED_ARRAY_HPP_INCLUDED + +#include +#include + +namespace boost { + +template +struct is_bounded_array + : false_type { }; + +#if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS) +template +struct is_bounded_array + : true_type { }; + +template +struct is_bounded_array + : true_type { }; + +template +struct is_bounded_array + : true_type { }; + +template +struct is_bounded_array + : true_type { }; +#endif + +} /* boost */ + +#endif diff --git a/include/boost/type_traits/is_unbounded_array.hpp b/include/boost/type_traits/is_unbounded_array.hpp new file mode 100644 index 0000000..1bacfdc --- /dev/null +++ b/include/boost/type_traits/is_unbounded_array.hpp @@ -0,0 +1,41 @@ +/* +Copyright 2018 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, +Version 1.0. (See accompanying file LICENSE_1_0.txt +or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +#ifndef BOOST_TT_IS_UNBOUNDED_ARRAY_HPP_INCLUDED +#define BOOST_TT_IS_UNBOUNDED_ARRAY_HPP_INCLUDED + +#include + +namespace boost { + +template +struct is_unbounded_array + : false_type { }; + +#if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS) +template +struct is_unbounded_array + : true_type { }; + +template +struct is_unbounded_array + : true_type { }; + +template +struct is_unbounded_array + : true_type { }; + +template +struct is_unbounded_array + : true_type { }; +#endif + +} /* boost */ + +#endif diff --git a/test/is_bounded_array_test.cpp b/test/is_bounded_array_test.cpp new file mode 100644 index 0000000..ac5fcbf --- /dev/null +++ b/test/is_bounded_array_test.cpp @@ -0,0 +1,35 @@ +/* +Copyright 2018 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, +Version 1.0. (See accompanying file LICENSE_1_0.txt +or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ +#ifdef TEST_STD +#include +#else +#include +#endif +#include "check_integral_constant.hpp" + +TT_TEST_BEGIN(is_bounded_array) + +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_bounded_array::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_bounded_array::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_bounded_array::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_bounded_array::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_bounded_array::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_bounded_array::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_bounded_array::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_bounded_array::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_bounded_array::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_bounded_array::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_bounded_array::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_bounded_array::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_bounded_array::value, false); +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_bounded_array::value, false); +#endif + +TT_TEST_END diff --git a/test/is_unbounded_array_test.cpp b/test/is_unbounded_array_test.cpp new file mode 100644 index 0000000..262a6bb --- /dev/null +++ b/test/is_unbounded_array_test.cpp @@ -0,0 +1,35 @@ +/* +Copyright 2018 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, +Version 1.0. (See accompanying file LICENSE_1_0.txt +or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ +#ifdef TEST_STD +#include +#else +#include +#endif +#include "check_integral_constant.hpp" + +TT_TEST_BEGIN(is_unbounded_array) + +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_unbounded_array::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_unbounded_array::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_unbounded_array::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_unbounded_array::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_unbounded_array::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_unbounded_array::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_unbounded_array::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_unbounded_array::value, false); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_unbounded_array::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_unbounded_array::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_unbounded_array::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_unbounded_array::value, true); +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_unbounded_array::value, false); +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES +BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_unbounded_array::value, false); +#endif + +TT_TEST_END