Commit Graph

406 Commits

Author SHA1 Message Date
Johel Ernesto Guerrero Peña
c9fde56eab Don't install UnitTest++ 2017-03-12 20:40:45 -04:00
Johel Ernesto Guerrero Peña
8782e6c6c4 Make GSL a CMake consumable header-only library 2017-03-12 17:46:21 -04:00
zhykzhykzhyk
5905d2d774 Fix links in README.md (#457) 2017-03-10 09:55:24 -08:00
Duncan Horn
2676e172db Updating length_func<CharT>::operator() to accept pointer-to-const. (#458) 2017-03-10 09:02:13 -08:00
Rian Quinn
f9c47dd63f add gsl::not_null operator<< (#464)
* add gsl::not_null operator<<

Hippomocks, which is a popular mocking engine for C++ uses operator<< on pointers and gets confused about gsl::not_null not having this operator.

* Update gsl
2017-03-09 12:42:18 -08:00
Casey Carter
3819df6e37 Properly qualify std::size_t (#448) 2017-02-13 12:11:45 -08:00
mkluwe
a6baab7c01 Update README.md (#454)
* Update README.md

edited link to the `gsl` include directory

* Update README.md

added `include` to the include path according to the directory structure
2017-02-13 11:47:04 -08:00
Casey Carter
e3fecbd1c5 not_null cleanups and improvements: (#449)
* constexpr all the things.

* remove operator=(const T&)
  * it leaves *this in an invalid state if ensure_invariant fails
  * implicitly converting the T to not_null and then assigning is in every way superior.

* simplify conversion from not_null<U> with constructor delegation.

* remove the converting assignment operator; again let the conversion constructor and self-assignment operator do the work.

* Cover the remaining pointer arithmetic operations as Wakely suggests in issue #447.

* Cleanup not_null conversions from null pointer constants:

  * replace constructor that accepts T with constructor template that accepts U convertible to T

  * remove deleted constructor that accepts int

  * Attempts to initialize with nullptr, 0, 0L, 0LL, etc. all unambiguously select the deleted nullptr_t constructor.
2017-02-13 11:40:27 -08:00
Casey Carter
6367b42ac5 Silence warning in algorithm_tests with VS2017 (#453)
Now that the STL respects /W4, this test that uses std::copy_n to copy a span of ints to a span of chars triggers "warning C4244: '=': conversion from 'int' to 'char', possible loss of data". Switch the source & destination spans to short and int to maintain the test's cross-type nature but without narrowing.
2017-02-13 11:25:09 -08:00
Casey Carter
6360dd1e75 Revert change to the definition of constexpr macro in gsl_byte from #446 (#450) 2017-02-11 17:38:59 -08:00
Casey Carter
4e8f95b418 Cleanup include structure, constexpr and noexcept compiler workarounds.
* Nest "gsl" directory inside a new "include" directory.

* Cleanup the _MSC_VER conditionals a bit; use constexpr on VS2017+.

* Don't #define noexcept on non-Microsoft implementations.

* Workaround VS2017 bug in multi_span. (Also implement == and != for static_bounds_dynamic_range_t because I'm an EoP semantic soundness snob.)

Fixes #441.
2017-02-07 15:59:37 -08:00
Casey Carter
96eaf274f8 Make is_default_constructible work for spans. 2017-01-28 00:08:48 -08:00
Tobias Hunger
f93d325495 Fix gsl_byte to include type_traits
type_traits are needed for the call to std::is_same.
2017-01-23 17:07:12 -08:00
Neil MacIntosh
18e3825cc0 Updated README.md to mention VS natvis file. 2017-01-14 17:15:24 -08:00
Gabriel M
0ed032fb13 Add Visual Studio Native Visualiser support file. 2017-01-14 17:10:22 -08:00
ErnestPenfold
897cc48f70 Fix #pragma warning push/pop mismatch in multi_span (Issue #431)
Rearranged preprocessor code at end of file multi_span
2017-01-09 16:38:38 -08:00
Eric Niebler
9d13cb14c3 Fixes to typedef's for span::const_iterator.
* Don't const-qualify span::const_iterator's value_type
Fixes Microsoft/GSL#434
2016-12-09 20:19:50 -08:00
Gary Furnish
1a94e77910 Fix preprocessor error. 2016-12-06 16:40:09 -08:00
Neil MacIntosh
628d3e8546 Updated README to refer to VS 2017 2016-11-29 18:34:51 -08:00
David Doria
c52d54f955 Fix a signed/unsigned comparison warning. 2016-11-29 18:08:32 -08:00
MikeGitb
d2dafe2ddf Add a copy() function for span. 2016-11-17 10:45:06 -08:00
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