Commit Graph

192 Commits

Author SHA1 Message Date
Galik
74a7ed4bc1 Applied clang-format -i -style=file -assume-filename=cpp
include/gsl/gsl_thread
2017-04-18 04:39:16 +01:00
Galik
a19d1b0964 Add: #include <gsl/gsl_thread> in master header <gsl/gsl> 2017-04-15 23:01:09 +01:00
Galik
cb9287b281 Add: include/gsl/gsl_thread header 2017-04-04 16:59:05 +01: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
Neil MacIntosh
8855c59579 Added basic compile support for MSVC 2013 to byte. 2016-07-15 17:31:40 -07:00
Neil MacIntosh
267472449c Renamed byte header and tidied up string_span dependencies. 2016-06-26 17:00:56 +03:00
Neil MacIntosh
b72d7abfb0 Added definition of gsl::byte to match proposed std::byte. 2016-06-24 04:54:09 -07:00
Neil MacIntosh
7b00172f00 Final sync with D0122R3 version of specification. 2016-06-20 01:41:49 -07:00
Neil MacIntosh
64598bc0f7 Cleaned up last() functions to match spec. 2016-06-14 20:20:09 -07:00
Neil MacIntosh
62f30205e5 Additional std::array ctor to support const element cases. 2016-06-14 20:14:17 -07:00
Neil MacIntosh
c94a66f468 Tightened SFINAE for span<U> to span<T> conversions. 2016-06-12 18:28:19 -07:00
Neil MacIntosh
ba8ebef509 Added span to object rep conversions. 2016-05-29 17:06:29 -07:00
Neil MacIntosh
d63c9803da Added comparison operators. 2016-05-29 14:05:09 -07:00
Neil MacIntosh
25ff7eca1f Removed some redundant parens. 2016-05-29 13:54:19 -07:00
Neil MacIntosh
d9d6ff0121 Added iterators. 2016-05-29 13:52:28 -07:00
ericLemanissier
9d8866a732 gsl::at overload for initializer_list
initializer_list do not have subscript operator, so the generic container overload of gsl::at fails to compile.
This commits adds an overload of gsl::at for initializer_lists, using *(initializer_list::begin()+index) instead of subscript operator
2016-05-09 15:27:17 +02:00
Neil MacIntosh
a9f0ce2f77 Suppressed CppCoreCheck warnings. 2016-03-31 12:01:07 -07:00
Neil MacIntosh
c8a412f028 Implemented first, last, subspan. 2016-03-18 16:49:29 -07:00
Neil MacIntosh
3d4c34966a Fixed ctors for Container and std::array to accept temporaries. 2016-03-17 17:20:33 -07:00