mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Added new span-related files.
This commit is contained in:
parent
d2f12a8fa3
commit
cec26a23b9
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include "gsl_assert.h" // Ensures/Expects
|
#include "gsl_assert.h" // Ensures/Expects
|
||||||
#include "gsl_util.h" // finally()/narrow()/narrow_cast()...
|
#include "gsl_util.h" // finally()/narrow()/narrow_cast()...
|
||||||
//#include "span.h" // span
|
#include "span.h" // span
|
||||||
#include "multi_span.h" // multi_span, strided_span...
|
#include "multi_span.h" // multi_span, strided_span...
|
||||||
#include "string_span.h" // zstring, string_span, zstring_builder...
|
#include "string_span.h" // zstring, string_span, zstring_builder...
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef GSL_SPAN_H
|
#ifndef GSL_MULTI_SPAN_H
|
||||||
#define GSL_SPAN_H
|
#define GSL_MULTI_SPAN_H
|
||||||
|
|
||||||
#include "gsl_assert.h"
|
#include "gsl_assert.h"
|
||||||
#include "gsl_util.h"
|
#include "gsl_util.h"
|
||||||
@ -2221,4 +2221,4 @@ general_span_iterator<Span> operator+(typename general_span_iterator<Span>::diff
|
|||||||
|
|
||||||
#endif // GSL_THROW_ON_CONTRACT_VIOLATION
|
#endif // GSL_THROW_ON_CONTRACT_VIOLATION
|
||||||
|
|
||||||
#endif // GSL_SPAN_H
|
#endif // GSL_MULTI_SPAN_H
|
||||||
|
115
include/span.h
Normal file
115
include/span.h
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef GSL_SPAN_H
|
||||||
|
#define GSL_SPAN_H
|
||||||
|
|
||||||
|
#include "gsl_assert.h"
|
||||||
|
#include "gsl_util.h"
|
||||||
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <functional>
|
||||||
|
#include <iterator>
|
||||||
|
#include <limits>
|
||||||
|
#include <new>
|
||||||
|
#include <numeric>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
// turn off some warnings that are noisy about our Expects statements
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4127) // conditional expression is constant
|
||||||
|
|
||||||
|
// No MSVC does constexpr fully yet
|
||||||
|
#pragma push_macro("constexpr")
|
||||||
|
#define constexpr
|
||||||
|
|
||||||
|
// VS 2013 workarounds
|
||||||
|
#if _MSC_VER <= 1800
|
||||||
|
|
||||||
|
#define GSL_MSVC_HAS_VARIADIC_CTOR_BUG
|
||||||
|
#define GSL_MSVC_NO_SUPPORT_FOR_MOVE_CTOR_DEFAULT
|
||||||
|
|
||||||
|
// noexcept is not understood
|
||||||
|
#ifndef GSL_THROW_ON_CONTRACT_VIOLATION
|
||||||
|
#pragma push_macro("noexcept")
|
||||||
|
#define noexcept /* nothing */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// turn off some misguided warnings
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable : 4351) // warns about newly introduced aggregate initializer behavior
|
||||||
|
#pragma warning(disable : 4512) // warns that assignment op could not be generated
|
||||||
|
|
||||||
|
#endif // _MSC_VER <= 1800
|
||||||
|
|
||||||
|
#endif // _MSC_VER
|
||||||
|
|
||||||
|
#ifdef GSL_THROW_ON_CONTRACT_VIOLATION
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma push_macro("noexcept")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define noexcept /* nothing */
|
||||||
|
|
||||||
|
#endif // GSL_THROW_ON_CONTRACT_VIOLATION
|
||||||
|
|
||||||
|
namespace gsl
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace gsl
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
#undef constexpr
|
||||||
|
#pragma pop_macro("constexpr")
|
||||||
|
|
||||||
|
#if _MSC_VER <= 1800
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
||||||
|
#ifndef GSL_THROW_ON_CONTRACT_VIOLATION
|
||||||
|
#undef noexcept
|
||||||
|
#pragma pop_macro("noexcept")
|
||||||
|
#endif // GSL_THROW_ON_CONTRACT_VIOLATION
|
||||||
|
|
||||||
|
#undef GSL_MSVC_HAS_VARIADIC_CTOR_BUG
|
||||||
|
|
||||||
|
#endif // _MSC_VER <= 1800
|
||||||
|
|
||||||
|
#endif // _MSC_VER
|
||||||
|
|
||||||
|
#if defined(GSL_THROW_ON_CONTRACT_VIOLATION)
|
||||||
|
|
||||||
|
#undef noexcept
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#pragma pop_macro("noexcept")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // GSL_THROW_ON_CONTRACT_VIOLATION
|
||||||
|
|
||||||
|
#endif // GSL_SPAN_H
|
@ -33,7 +33,7 @@ if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/unittest-cpp)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
function(add_gsl_test name)
|
function(add_gsl_test name)
|
||||||
add_executable(${name} ${name}.cpp ../include/gsl.h ../include/gsl_assert.h ../include/gsl_util.h ../include/multi_span.h ../include/string_span.h)
|
add_executable(${name} ${name}.cpp ../include/gsl.h ../include/gsl_assert.h ../include/gsl_util.h ../include/multi_span.h ../include/span.h ../include/string_span.h)
|
||||||
target_link_libraries(${name} UnitTest++)
|
target_link_libraries(${name} UnitTest++)
|
||||||
install(TARGETS ${name}
|
install(TARGETS ${name}
|
||||||
RUNTIME DESTINATION bin
|
RUNTIME DESTINATION bin
|
||||||
@ -44,6 +44,7 @@ function(add_gsl_test name)
|
|||||||
)
|
)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
add_gsl_test(span_tests)
|
||||||
add_gsl_test(multi_span_tests)
|
add_gsl_test(multi_span_tests)
|
||||||
add_gsl_test(strided_span_tests)
|
add_gsl_test(strided_span_tests)
|
||||||
add_gsl_test(string_span_tests)
|
add_gsl_test(string_span_tests)
|
||||||
|
1680
tests/span_tests.cpp
Normal file
1680
tests/span_tests.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user