Neil MacIntosh | cec26a2 | 2016-02-24 11:26:28 -0800 | [diff] [blame^] | 1 | /////////////////////////////////////////////////////////////////////////////// |
| 2 | // |
| 3 | // Copyright (c) 2015 Microsoft Corporation. All rights reserved. |
| 4 | // |
| 5 | // This code is licensed under the MIT License (MIT). |
| 6 | // |
| 7 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 8 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 9 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 10 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 11 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 12 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 13 | // THE SOFTWARE. |
| 14 | // |
| 15 | /////////////////////////////////////////////////////////////////////////////// |
| 16 | |
| 17 | #pragma once |
| 18 | |
| 19 | #ifndef GSL_SPAN_H |
| 20 | #define GSL_SPAN_H |
| 21 | |
| 22 | #include "gsl_assert.h" |
| 23 | #include "gsl_util.h" |
| 24 | #include <algorithm> |
| 25 | #include <array> |
| 26 | #include <cassert> |
| 27 | #include <cstddef> |
| 28 | #include <cstdint> |
| 29 | #include <functional> |
| 30 | #include <iterator> |
| 31 | #include <limits> |
| 32 | #include <new> |
| 33 | #include <numeric> |
| 34 | #include <stdexcept> |
| 35 | #include <type_traits> |
| 36 | #include <utility> |
| 37 | |
| 38 | #ifdef _MSC_VER |
| 39 | |
| 40 | // turn off some warnings that are noisy about our Expects statements |
| 41 | #pragma warning(push) |
| 42 | #pragma warning(disable : 4127) // conditional expression is constant |
| 43 | |
| 44 | // No MSVC does constexpr fully yet |
| 45 | #pragma push_macro("constexpr") |
| 46 | #define constexpr |
| 47 | |
| 48 | // VS 2013 workarounds |
| 49 | #if _MSC_VER <= 1800 |
| 50 | |
| 51 | #define GSL_MSVC_HAS_VARIADIC_CTOR_BUG |
| 52 | #define GSL_MSVC_NO_SUPPORT_FOR_MOVE_CTOR_DEFAULT |
| 53 | |
| 54 | // noexcept is not understood |
| 55 | #ifndef GSL_THROW_ON_CONTRACT_VIOLATION |
| 56 | #pragma push_macro("noexcept") |
| 57 | #define noexcept /* nothing */ |
| 58 | #endif |
| 59 | |
| 60 | // turn off some misguided warnings |
| 61 | #pragma warning(push) |
| 62 | #pragma warning(disable : 4351) // warns about newly introduced aggregate initializer behavior |
| 63 | #pragma warning(disable : 4512) // warns that assignment op could not be generated |
| 64 | |
| 65 | #endif // _MSC_VER <= 1800 |
| 66 | |
| 67 | #endif // _MSC_VER |
| 68 | |
| 69 | #ifdef GSL_THROW_ON_CONTRACT_VIOLATION |
| 70 | |
| 71 | #ifdef _MSC_VER |
| 72 | #pragma push_macro("noexcept") |
| 73 | #endif |
| 74 | |
| 75 | #define noexcept /* nothing */ |
| 76 | |
| 77 | #endif // GSL_THROW_ON_CONTRACT_VIOLATION |
| 78 | |
| 79 | namespace gsl |
| 80 | { |
| 81 | |
| 82 | |
| 83 | } // namespace gsl |
| 84 | |
| 85 | #ifdef _MSC_VER |
| 86 | |
| 87 | #undef constexpr |
| 88 | #pragma pop_macro("constexpr") |
| 89 | |
| 90 | #if _MSC_VER <= 1800 |
| 91 | #pragma warning(pop) |
| 92 | |
| 93 | #ifndef GSL_THROW_ON_CONTRACT_VIOLATION |
| 94 | #undef noexcept |
| 95 | #pragma pop_macro("noexcept") |
| 96 | #endif // GSL_THROW_ON_CONTRACT_VIOLATION |
| 97 | |
| 98 | #undef GSL_MSVC_HAS_VARIADIC_CTOR_BUG |
| 99 | |
| 100 | #endif // _MSC_VER <= 1800 |
| 101 | |
| 102 | #endif // _MSC_VER |
| 103 | |
| 104 | #if defined(GSL_THROW_ON_CONTRACT_VIOLATION) |
| 105 | |
| 106 | #undef noexcept |
| 107 | |
| 108 | #ifdef _MSC_VER |
| 109 | #pragma warning(pop) |
| 110 | #pragma pop_macro("noexcept") |
| 111 | #endif |
| 112 | |
| 113 | #endif // GSL_THROW_ON_CONTRACT_VIOLATION |
| 114 | |
| 115 | #endif // GSL_SPAN_H |