moved gsl::index to gsl_util

This commit is contained in:
Pawel Dac 2018-02-15 21:51:40 +01:00
parent 2e4213a11a
commit 8f5110b8ae
6 changed files with 14 additions and 59 deletions

View File

@ -21,7 +21,6 @@
#include <gsl/gsl_assert> // Ensures/Expects #include <gsl/gsl_assert> // Ensures/Expects
#include <gsl/gsl_byte> // byte #include <gsl/gsl_byte> // byte
#include <gsl/gsl_util> // finally()/narrow()/narrow_cast()... #include <gsl/gsl_util> // finally()/narrow()/narrow_cast()...
#include <gsl/index> // index
#include <gsl/multi_span> // multi_span, strided_span... #include <gsl/multi_span> // multi_span, strided_span...
#include <gsl/pointers> // owner, not_null #include <gsl/pointers> // owner, not_null
#include <gsl/span> // span #include <gsl/span> // span

View File

@ -43,6 +43,9 @@ namespace gsl
// GSL.util: utilities // GSL.util: utilities
// //
// index type for all container indexes/subscripts/sizes
using index = std::ptrdiff_t;
// final_action allows you to ensure something gets run at the end of a scope // final_action allows you to ensure something gets run at the end of a scope
template <class F> template <class F>
class final_action class final_action

View File

@ -1,27 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
//
// 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 <cstddef> // for ptrdiff_t
namespace gsl
{
using index = std::ptrdiff_t;
}
#endif // GSL_INDEX_H

View File

@ -101,4 +101,3 @@ add_gsl_test(utils_tests)
add_gsl_test(owner_tests) add_gsl_test(owner_tests)
add_gsl_test(byte_tests) add_gsl_test(byte_tests)
add_gsl_test(algorithm_tests) add_gsl_test(algorithm_tests)
add_gsl_test(index_test)

View File

@ -1,26 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
//
// 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 <catch/catch.hpp>
#include <type_traits> // for is_same
#include <gsl/index> // for index
TEST_CASE("sanity check for gsl::index typedef")
{
static_assert(std::is_same<gsl::index, std::ptrdiff_t>::value,
"gsl::index represents wrong arithmetic type");
}

View File

@ -22,9 +22,16 @@
#include <functional> // for reference_wrapper, _Bind_helper<>::type #include <functional> // for reference_wrapper, _Bind_helper<>::type
#include <limits> // for numeric_limits #include <limits> // for numeric_limits
#include <stdint.h> // for uint32_t, int32_t #include <stdint.h> // for uint32_t, int32_t
#include <type_traits> // for is_same
using namespace gsl; using namespace gsl;
TEST_CASE("sanity check for gsl::index typedef")
{
static_assert(std::is_same<gsl::index, std::ptrdiff_t>::value,
"gsl::index represents wrong arithmetic type");
}
void f(int& i) { i += 1; } void f(int& i) { i += 1; }
TEST_CASE("finally_lambda") TEST_CASE("finally_lambda")