Commit Graph

171 Commits

Author SHA1 Message Date
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