diff --git a/include/gsl/gsl b/include/gsl/gsl index 55862eb..6415d48 100644 --- a/include/gsl/gsl +++ b/include/gsl/gsl @@ -21,6 +21,7 @@ #include // Ensures/Expects #include // byte #include // finally()/narrow()/narrow_cast()... +#include // index #include // multi_span, strided_span... #include // owner, not_null #include // span diff --git a/include/gsl/index b/include/gsl/index new file mode 100644 index 0000000..176860c --- /dev/null +++ b/include/gsl/index @@ -0,0 +1,27 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2015 Microsoft Corporation. All rights reserved. +// +// This code is licensed under the MIT License (MIT). +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef GSL_INDEX_H +#define GSL_INDEX_H + +#include // for ptrdiff_t + +namespace gsl +{ +using index = std::ptrdiff_t; +} + +#endif // GSL_INDEX_H diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 86ce5a4..544d1cc 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -101,3 +101,4 @@ add_gsl_test(utils_tests) add_gsl_test(owner_tests) add_gsl_test(byte_tests) add_gsl_test(algorithm_tests) +add_gsl_test(index_test) diff --git a/tests/index_test.cpp b/tests/index_test.cpp new file mode 100644 index 0000000..761e70f --- /dev/null +++ b/tests/index_test.cpp @@ -0,0 +1,26 @@ +/////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2015 Microsoft Corporation. All rights reserved. +// +// This code is licensed under the MIT License (MIT). +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +/////////////////////////////////////////////////////////////////////////////// + +#include +#include // for is_same + +#include // for index + +TEST_CASE("sanity check for gsl::index typedef") +{ + static_assert(std::is_same::value, + "gsl::index represents wrong arithmetic type"); +}