Commit Graph

207 Commits

Author SHA1 Message Date
Rian Quinn
842344e94b turning off warning (#548)
using the GSL with MSVC 2017 causes the following warning"
`'std::copy_n::_Unchecked_iterators::_Deprecate': Call to 'std::copy_n'`

This patch removes this since the point of this code is to deal with this issue.
2017-08-16 19:06:30 -07:00
Casey Carter
2b8d20425e Allow users to override GSL_USE_STD_BYTE (#536) 2017-07-24 17:26:21 -07:00
Neil MacIntosh
be43c79742 Removed VS2013 workarounds. (#534) 2017-07-14 04:40:27 -07:00
Neil MacIntosh
b2ee484334 Move from unittest-cpp to catch for unit testing. (#533)
Many thanks to @rianquinn. This should fix #495, #494 and #529.
2017-07-13 13:53:56 -07:00
Gary Furnish
1f87ef73f1 Fix cstddef include in wrong place. (#520) 2017-06-02 08:45:42 -07:00
Vincent Zalzal
010ab921bf Fix multi_span constructor taking a const std::array. (#523)
not called even by the unit test (it was calling the "container" ctor
instead). I mimicked the constructor taking a non-const std::array to fix
the issue.
2017-06-01 21:55:25 -07:00
Neil MacIntosh
1cfb241be7 Fix bug in comparison that selects std::byte. 2017-05-31 19:08:11 -07:00
Neil MacIntosh
7731a91d75 Use std::byte when available. (#519)
* Use std::byte implementation when available with MSVC.

* Rollback the /std:c++latest flag used for testing.

* Review feedback.
2017-05-31 18:42:06 -07:00
Alexey Malov
247c4250d4 Fixes dereferencing operator issue #517 introduced in PR #513 (#516)
* Fixes issue with dereferencing operator issue #491 introduced in PR #513

dereferencing operator added in PR#513 returned a copy of the object
instead of reference to it.
Adding decltype(auto) as return type of operator* fixes this issue.

* added more tests for not_null::operator*
2017-05-31 11:18:55 -07:00
saurabh singh
30595c1f1d Restricting usage of owner<T> to pointer types (#507)
* Restricting usage of owner<T> to pointer types

* Removing an additional type that was created for testing

* Added comment about the new constraint on owner

* Adding dereference operator to not_null

* Removing dereference operator changes for not-null

* Removing dereference operator changes for not-null

* Review comments
2017-05-30 20:08:12 -07:00
saurabh singh
23581d4d63 Adding derference operator to not_null (#513) 2017-05-30 10:06:21 -07:00
Gary Furnish
d1032864aa Fix use of 0 instead of nullptr warning (#515) 2017-05-30 09:57:45 -07:00
Galik
7abfc98198 GSL_NOEXCEPT should appear before the initialization list (#514) 2017-05-30 08:09:09 -07:00
Casey Carter
39902b6ec0 span_iterator: converting constructor isn't a copy constructor (#511)
Fixes #510.

* Constrain the converting constructor to not participate in overload resolution when IsConst is true, so that it is never a copy constructor.
* Use Default Member Initializers for span_iterator's data members so that the default constructor can be explicitly defaulted.
* Declare all members of span_iterator GSL_NOEXCEPT: they only throw when contract violations throw.
* Don't use & in operator-> since evil types may overload it.
2017-05-26 15:41:12 -07:00
ewoudvc
64c0ca64ce make_span for array doesn't pass N as span template parameter (#498) 2017-04-25 12:01:49 -07:00
Tiago
ebe7ebfd85 Reformat files to follow clang-format style (#492)
Project files were not following the clang-format style. For people
using IDEs were clang-format is always run after a save this would
cause unwanted changes.

This commit only applies "clang-format -i" to files.
2017-04-20 07:51:37 -07:00
Maciej T. Nowak
c2f953f2eb Add value_type to span (#425)
* Add value_type to span

Currently I'm working on project which involves a lot of `span`s and mocking via Google Mock. Unfortunately a lot of standard matchers requires `value_type` type definition inside container which `gsl::span` lacks.

This pull request add `value_type` type definition inside `gsl::span`

* Strip cv from value_type of span and span_iterator
2017-04-13 13:55:20 -07:00
Alexey Malov
534bb4c663 Added support of not_null<smart_ptr> comparison (#473)
* Added support of not_null<smart_ptr> comparison

* The return type of not_null comparison operators is determined using SFINAE
#474

* tests for gsl::not_null comparison were added

* not_null comparison tests were rewritten to compare pointers to objects located in the same array

* not_null<shared_ptr> comparison was simplified
2017-04-12 17:34:39 -07:00
Casey Carter
ebab8cab7f gsl::at clean-up: (#479)
* initializer_list overload returns by value to avoid lifetime issues

* generic overload uses expression SFINAE to work with any type that has member size() and operator[], which notably includes const/non-const vector and array.

* Add test coverage for const objects, rvalue initializer_lists, and constexpr usage.

Fixes #357.
2017-04-03 22:43:43 -07:00
Casey Carter
d65660760b fail_fast should derive from logic_error (#480)
Fixes #298.
2017-04-03 11:09:47 -07:00
MikeGitb
ade86caa92 Fix some corechecker warnings (#470)
* Improve const correctness in string_span

* Improve const correctness in bounds_tests.cpp and byte_tests.cpp

* Improve const correctness in span_tests.cpp

* Improve const correctness in utils_tests.cpp

* Use gsl::owner for dynamically allocated memory in string_span_tests.cpp

* Improve const correctness in string_span_tests.cpp

* Improve const correctness for strided_span_tests.cpp
2017-04-02 12:30:49 -07:00
Casey Carter
16a6a41690 gsl_assert changes: (#452)
* GSL_LIKELY/_UNLIKELY always contextually convert their argument to bool.

* Add macro GSL_ASSUME(cond) to inform the optimizer that the predicate cond must hold.

* Reimplement Expects & Ensures as expressions for flexibility and correctness. (Think about "if (cond1) Expects(cond2); else goto fail;")

* Expects and Ensures GSL_ASSUME their predicate when GSL_UNENFORCED_ON_CONTRACT_VIOLATION is defined.
2017-03-20 09:30:14 -07: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
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
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
galik
f6cc5798a1 Renamed include/ folder to gsl/ to make including the library consistent
whether using it from the development folder, from the installation
folder or from being copied into a project. 

    #include <gsl/gsl.h>

Updated headers/tests/instructions/cmake build accordingly

This PR should address https://github.com/Microsoft/GSL/issues/277 (less
the renaming of gsl itself)
2016-08-09 15:04:58 +01:00
Neil MacIntosh
efeb557bf1 Merge pull request #310 from neilmacintosh/dev/neilmac/fix_mismatched_pragma
Fixed #308 - a mismatched pragma.
2016-08-08 13:52:15 -07:00
Som1Lse
c4817358aa Implemented https://github.com/Microsoft/GSL/issues/260 2016-08-03 22:28:25 +02:00
Neil MacIntosh
db9d3da029 Merge branch 'master' of https://github.com/neilmacintosh/GSL into dev/neilmac/fix_mismatched_pragma 2016-08-02 18:10:07 -07:00
Neil MacIntosh
ebce4920d6 Fixed #308 - a mismatched pragma. 2016-08-02 16:22:18 -07:00
Neil MacIntosh
6c7be2c8ee clang-format run. 2016-08-01 21:41:20 -07:00
Neil MacIntosh
94afa1fbd7 Removed unnecessary inheritance between iterators. 2016-08-01 18:49:48 -07:00
Neil MacIntosh
1bd2d04c2e Another round of clang-formatting. 2016-08-01 13:10:02 -07:00
Neil MacIntosh
8e31f53f8a Building clean with MSVC12. 2016-07-29 11:16:06 -07:00
Neil MacIntosh
a0cf1ecc49 Renamed as_span() to as_multi_span() for clarity. 2016-07-28 17:27:22 -07:00
Neil MacIntosh
a88cfb168a Fixed type-name mixup in string_span. 2016-07-27 13:48:29 -07:00
Neil MacIntosh
6fadce975b Applied clang-format. 2016-07-26 19:19:47 -07:00
Neil MacIntosh
4de3d4e3e3 Fixes for Clang 3.6 compilation. 2016-07-26 18:44:13 -07:00
Neil MacIntosh
c366f4415d Fixed compilation issues for GCC on Linux. 2016-07-26 18:34:27 -07:00
Neil MacIntosh
b03b04bfcd Applied clang-format to the source. 2016-07-20 13:17:47 -07:00
Neil MacIntosh
cd80ef6146 Merge branch 'master' into dev/neilmac/spec 2016-07-20 12:02:51 -07:00
Neil MacIntosh
eed99d8599 Merge branch 'master' into dev/neilmac/spec 2016-07-20 09:30:05 -07:00
Neil MacIntosh
f2ab3a5c54 Tidying up noexcepts. 2016-07-20 09:24:49 -07:00
Neil MacIntosh
5e7771f879 Slight tidy-up to precondition checking in span. 2016-07-20 09:00:10 -07:00
Neil MacIntosh
0c1b6717c1 Weakened cast in span::iterator. 2016-07-20 08:52:09 -07:00
Neil MacIntosh
520c72d777 Tidied up assertion. 2016-07-18 12:00:33 -07:00
Neil MacIntosh
30a038ca6a Added tests for span iterators, fixed implementation. 2016-07-18 11:38:01 -07:00