Bond
 
Loading...
Searching...
No Matches
sdl.h
1// Copyright (c) Microsoft. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4/* Microsoft publishes the Security Development Lifecycle (SDL) which "is a
5 * software development process that helps developers build more secure
6 * software and address security compliance requirements while reducing
7 * development cost."
8 *
9 * Some more details at https://www.microsoft.com/en-us/sdl/
10 *
11 * The code in this file allows Bond to access features in MSVC that are
12 * specific to the SDL while maintaining Bond's cross-compiler and
13 * cross-platform compability.
14 */
15
16#pragma once
17
18#include <bond/core/config.h>
19
20#include <boost/assert.hpp>
21#include <boost/core/ignore_unused.hpp>
22#include <iterator>
23
24namespace bond { namespace detail
25{
26
27#ifdef _MSC_VER
28
29template<class Iterator> inline
30stdext::checked_array_iterator<Iterator> make_checked_array_iterator(
31 Iterator array,
32 size_t size,
33 size_t index = 0)
34{
35 // Allows algorithms like std::copy to work on pointers by encoding
36 // bounds information.
37 return stdext::checked_array_iterator<Iterator>(array, size, index);
38}
39
40#else
41
42template<class Iterator> inline
43Iterator make_checked_array_iterator(
44 Iterator array,
45 size_t size,
46 size_t index = 0)
47{
48 boost::ignore_unused(size);
49 BOOST_ASSERT(index <= size);
50
51 return array + index;
52}
53
54#endif
55
56}}
namespace bond
Definition: apply.h:17