Commit Graph

735 Commits

Author SHA1 Message Date
Rian Quinn
2df9f85385 Add make_span()
This patch provides a make_span function to simplify the
creation of spans until C++17 is available. In addition
this patch updates the unit tests to includes tests that
verify this new functionality.
2016-11-16 10:17:04 -08:00
Neil MacIntosh
9523c1842e Fix template pack expansion bug in multi_span.
* Fix issue #333 by moving a parenthesis.
* Added test to prove fix is good.
2016-11-16 10:15:04 -08:00
Rian Quinn
bdcef948a5 Cleanup compiler warnings
The unique_ptr / shared_ptr patch introduced a compiler
warning. This corrects that issue.
2016-11-16 09:42:46 -08:00
Neil MacIntosh
a8c794602a Updated README.md for Visual Studio "15" support. 2016-11-04 14:50:08 -07:00
Neil MacIntosh
0d31109d41 Fixed compile flags for tests when using MSVC. 2016-11-04 14:48:22 -07:00
Rian Quinn
2b51b8767a Add span construction from unique_ptr and shared_ptr
This patch adds support for std::unique_ptr and
std::shared_ptr to the gsl::span
class instead of having to manually grab the pointer via
get().

For reference, this is part of the following issue:
https://github.com/Microsoft/GSL/issues/402
2016-11-03 18:55:41 -07:00
Rian Quinn
d641796b21 Cleanup additional GCC warnings
When turning on the following flags, several additional warnings
were generated, which have been cleaned up in this patch. The
flags included:

-Wextra
-Wpedantic
-Wconversion
-Wsign-conversion
-Wctor-dtor-privacy
-Wshadow
-Wnon-virtual-dtor
-Wold-style-cast
-Wcast-align
-Woverloaded-virtual
2016-11-03 18:38:32 -07:00
Vladislav Yaroslavlev
38f453d608 remove overly optimistic noexcept from some functions 2016-11-03 13:15:33 -07:00
Rian Quinn
fb1a89fb14 Fix gsl::at()'s use of size_t
gsl::at should use std::ptrdiff_t instead of size_t. This patch
fixes that, and adds missing unit tests
2016-10-28 11:46:14 -07:00
Rian Quinn
f4486389b8 Fix overflow found by GCC in basic_zstring_span::as_string_span().
This patch fixes an overflow that was identified with
strict overflow warnings enabled, and optimizations
turned on

Signed-off-by: “Rian <“rianquinn@gmail.com”>
2016-10-27 23:45:54 -07:00
Rian Quinn
6cffe0d14c Adds gsl::span::at()
As per this discussion:
https://github.com/Microsoft/GSL/issues/402

This patch adds support for at() to gsl::span
2016-10-26 14:11:24 -07:00
Rian Quinn
b07383ead1 [gsl_util] Update narrow_cast to use std::forward
* Update narrow_cast to use std::forward

Based on [F19](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#f19-for-forward-parameters-pass-by-tp-and-only-stdforward-the-parameter), I believe `gsl::narrow_cast` should be implemented using forward semantics.

* Fix for VS 2013
2016-10-18 11:52:45 -07:00
Marc Mutz
1e95421889 [#392] Don't install tests
'make install' should install the GSL library (ie. the headers),
not the tests.

It still installs the UnitTest++ headers, but that will be more
complex to fix, as GSL just imports UnitTest++ as a git submodule,
and the install command propagates down to UnitTest++'s
CMakeLists.txt.
2016-10-17 12:42:58 -07:00
Josaphat Valdivia
a14f27474f [#391] string_length: Remove use of strnlen and use consistent length type.
* Removes reference to strnlen as per #391

* Use ptrdiff for string_length interfaces for #391
2016-10-17 12:41:24 -07:00
MikeGitb
1287e624cd Address #313: try to guard against strict-aliasing bugs with gsl::byte
* Add test to demonstrate byte aliasing problem on g++ and clang++

* Add note about no-strict-aliasing flag in README

* Activate aliasing unit test and use -fno-strict-aliasing flag
2016-10-17 12:36:11 -07:00
Neil MacIntosh
9ef335ce32 Fix #388: Add explict default copy assignment operator for span_iterator 2016-10-11 16:13:52 -07:00
Gary Furnish
22a286cefe Fix #388 Deprecated implicit copy assignment operator for span_iterator in C++17. 2016-10-09 18:01:46 -06:00
Neil MacIntosh
32ca283d53 [span] fix size_t to index_type conversion warning 2016-10-05 08:41:58 -07:00
Gary Furnish
612747a5e1 For span, fix size_t to index_type conversion warning.
Use narrow per discussion instead of static_cast.
2016-10-04 21:13:18 -06:00
Neil MacIntosh
023652e304 [Travis] enlarge the support matrix 2016-09-30 14:52:36 -07:00
Casey Carter
f953b792f0 [Travis] enlarge the support matrix
* Build on OSX with Xcode 8
* Build on Linux with Clang 3.6/7/8 and libc++
* Build on Linux with GCC 5/6
2016-09-30 13:42:25 -07:00
Neil MacIntosh
0edabdba0c Add branch prediction to Ensures / Expects 2016-09-29 12:58:55 -07:00
Neil MacIntosh
3e5af6dc40 Fix compilation issues with Cygwin 2016-09-29 12:51:37 -07:00
Neil MacIntosh
e898a890e0 [multi_span] Fix UB hack in static_bounds::operator=(const static_bounds&) 2016-09-29 12:49:58 -07:00
Rian Quinn
9e055be659 Fix compilation issues with Cygwin
Cygwin recently did an update that broken string_span again. The original update had to provide a custom strnlen function because Cygwin doesn't implement this (it's a non-std extension). We never added wchar_t support, and the Cygwin update now breaks on exactly this. This patch provides the missing wchar_t.
2016-09-28 10:00:47 -06:00
Rian Quinn
3161d6133f Fix issue with VS builds
The Visual Studio part of this patch was wrong, and left an empty if statement.
2016-09-28 09:53:33 -06:00
Rian Quinn
4b29878d70 Add branch prediction to Ensures / Expects
We should be using branch prediction on asserts as these conditions are known to be unlikely, therefore we should be optimizing the likely case. These macros are similar to what the Linux kernel uses. Not really sure what Visual Studio does so at the moment these are disabled for VS.
2016-09-28 09:43:13 -06:00
Casey Carter
67717ea6ae [multi_span] Fix UB hack in static_bounds::operator=
* Make BoundsRanges<dynamic_range, ...>::m_bound non-const and private

* Remove various defaulted copy constructor/assignment declarations from BoundsRanges specializations whose only effect is to needlessly suppress the generation of moves

* Remove the hackish static_bounds::operator=(const static_bounds&). The implicitly generated default is now sufficient
2016-09-27 21:12:51 -07:00
Neil MacIntosh
348a859547 Removed redundant static_cast<> and is_same<> test. 2016-09-22 10:22:07 -07:00
Neil MacIntosh
e4a34128a8 Turn off warning about function-style casts in gsl_byte 2016-09-21 13:21:14 -07:00
Michael Balszun
4e7997190c Turn off warning about function-styl casts in gsl_byte 2016-09-21 21:39:28 +02:00
Neil MacIntosh
fd5ad87bf2 Add tests for to_integer(), fix to_integer() 2016-09-20 08:47:49 -07:00
Neil MacIntosh
e4de6cccdd Fix wrong types in multi_span_test for comparison operators. 2016-09-20 08:46:27 -07:00
Neil MacIntosh
75fb2236ed Fix negative indices to multi_span not being caught.
Negative indices to multi_span are not flagged with neither exception nor abort.
2016-09-20 08:44:41 -07:00
Krzysztof Wrzalik
6cb0e3082a Added a fix for not flagging negative indices to multi_span. 2016-09-18 17:56:18 +02:00
Krzysztof Wrzalik
22c2785452 Added tests for negative multi-span access. 2016-09-18 17:44:45 +02:00
Michael Balszun
95f465aeca fix wrong types in multi_span_test (<comparison_operators>) 2016-09-17 16:09:21 +02:00
Martin Moene
6cf154e067 Fix to_integer() 2016-09-17 09:24:34 +02:00
Martin Moene
ad991370da Add tests for to_integer(): they fail 2016-09-17 09:16:15 +02:00
Neil MacIntosh
831be5de39 Removed redundant static_cast<> and is_same<> test. 2016-09-14 22:01:02 -07:00
Neil MacIntosh
8361aae39e Adding inline to all byte-related functions for MSVC 2013. 2016-09-14 11:41:24 -07:00
Neil MacIntosh
edceed8075 Adding inline to all byte-related functions for MSVC 2013. 2016-09-13 14:30:02 -07:00
Neil MacIntosh
6bc1e7e709 Fix for #313 Corrected SFINAE for conversion constructors on span 2016-09-13 12:19:19 -07:00
Neil MacIntosh
e40729a561 Added inline to byte member functions to fix MSVC 2013 warnings 2016-09-13 12:17:17 -07:00
Neil MacIntosh
2d74fd5c84 Added to_byte() helper function to fix issue #329 2016-09-13 12:10:42 -07:00
Steve Brain
ad5275ca78 Added inline to fix compilation warnings on msvc 2013 2016-09-13 16:07:34 +10:00
Neil MacIntosh
bc70a93bba Removed unnecessary reinterpret_cast<> from span implementation. 2016-09-12 19:06:45 -07:00
Neil MacIntosh
3b2419532e Corrected SFINAE for conversion constructors on span. 2016-09-12 18:51:23 -07:00
Kris
d5847ceef0 Merge remote-tracking branch 'Microsoft/master' 2016-09-07 22:16:19 +01:00
Kris
7d083fd08c Issue #329, fixed build issues on clang
Fixed build issues that clang shows up the MS VS accepts.
2016-09-07 22:16:10 +01:00