Commit Graph

541 Commits

Author SHA1 Message Date
beinhaerter
fbe867a9c4 Fix clang-tidy warning about wrong comment on closing namespace (#654) 2018-04-24 19:04:24 -07:00
beinhaerter
697eb5533e final_action move assignment operator =delete against C26432 (#660)
This suppresses warning C26432 on VS2017. Fixes issue #653.
2018-04-24 18:35:53 -07:00
Stephan Dollberg
9c5e21045d Make gsl::details::throw_exception not copy exception object (#667)
This fixes the build with clang 7 which introduces a new warning
`-Wreturn-std-move` which warns about needless copies when a move
operation is available (see https://reviews.llvm.org/rL329914).

We take the exception object by uref so we should throw the forwarded
version.
2018-04-24 18:35:12 -07:00
Neil MacIntosh
d25969dbdf
Updated README to record another platform report.
As per #644.
2018-04-18 21:12:13 -07:00
Anna Gringauze
d846fe50a3
Enable usage of gsl::narrow with exceptions disabled (#640)
* Enable usage of gsl::narrow with exceptions disabled

This solution uses the approach of boost::asio to enabling usage of the
library in environments where exception usage is either prohibited
or not feasible (due to code size constraints). A function template
gsl::throw_exception has been added, which in a normal environment just
throws the exception. However, when GSL_TERMINATE_ON_CONTRACT_VIOLATION
is defined the function is only declared by gsl and the definition of
this function template must be supplied by the library's user.

Closes: #468

Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>

Addition:
- understand STL no exception macro
- use function static variable to set termination handler in kernel mode
- add compile-only tests for no-exception mode

* added termination tests and fixed bugs

* disabled warning C4577 for msvc 2015
2018-03-15 16:00:08 -07:00
Anna Gringauze
c6bf25a5f6
simplified constructors and removed GSL_NOEXCEPT in span (#639)
- simplified storage constructors to reduce branching
- eliminated null check for constructor from array
- removed GSL_NOEXCEPT in span
2018-03-15 12:14:29 -07:00
Alex Howlett
c9e423d7cf Fix warning 4996 on Microsoft compiler (#633) 2018-03-05 12:04:22 -08:00
Neil MacIntosh
6a33b97a84
Fix return type of templated span.subspan() (#625)
* Added support for returning fixed-spize spans from subspan().

* Addressed issues from code review.

* Took simpler approach to static data member.

* Subtle fix to support MSVC 15.

* Helps to not introduce extraneous >
2018-03-03 19:12:45 -08:00
Anna Gringauze
cbd64c9ff6 fixed noexept warnings (#632)
* fixed noexept warnings

- Removed conditional compilation for throwing version of GSL
  vs fail_fast because we don't want users of the code to see
  differences in the span interface dependent on error mechanism
  chosen
- Removed noexcept from functions that may fail at runtime
- Fixed CppCoreCheck warnings related to missing and incorrect
  noexcept
- do not warn on unnown attributes for GCC and Clang

* remove suppress that does not compiler for clang and gcc
2018-03-03 19:12:23 -08:00
Zac Hansen
ed3693fd2e make explicit not_null move constructor so it is noexcept (#630)
* make explicit not_null move constructor so it is noexcept

* added test for not_null being noexcet move constructible
2018-03-03 15:53:23 -08:00
beinhaerter
7eb8f41af5 constexpr for make_span (#627) 2018-02-23 13:35:36 -08:00
paweldac
b3870ca020 add gsl::index typedef (#620)
* rename index in multi_span to span_index

gsl::index is name reserved for different type

* add gsl::index typedef

cppcoreguidelines referece: ES.107: Don't use unsigned for subscripts, prefer gsl::index

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Res-subscripts

* rename span_index to multi_span_index
2018-02-21 13:33:07 -08:00
Johel Ernesto Guerrero Peña
73db6ef98f Remove inline added for the now unsupported MSVC 2013. (#585) 2018-02-20 14:46:37 -08:00
Neil MacIntosh
f8f265be84
Remove length synonym on span (#613) 2018-02-20 14:44:51 -08:00
caleb
13ce102ec0 gsl::index bug fix (#624)
Fixing a bug in the != operator in the gsl::index class
2018-02-20 14:37:50 -08:00
beinhaerter
c87c123d1b Fix code analysis warning in multi_span (#606)
Prevents MSVC code analysis warning
...\gsl\include\gsl\multi_span(1055): warning C26440: Function 'gsl::dim_t<-1>::dim_t<-1>' can be declared 'noexcept' (f.6: http://go.microsoft.com/fwlink/?linkid=853927).
2018-02-13 17:42:37 -08:00
Tamir Bahar
05bf567dcb Use in-class init for final_action members (C.48) (#601)
* Use in-class init for final_action members (C.48)

Initialize `invoke_` in-class, according to http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c48-prefer-in-class-initializers-to-member-initializers-in-constructors-for-constant-initializers

* Empty commit to trigger build.
2018-02-13 17:28:21 -08:00
Jérémie Delaitre
30b1641ff4 Fix wrong check of the CMAKE_VERSION (#602)
`CMAKE_VERSION_MAJOR` is just the first component of the CMake version (e.g. 3 for 3.10.1) which compares less than `3.7.9` if it is less than 3. The proper variable to compare is `CMAKE_VERSION` which contains the full version number.
2018-02-13 17:26:44 -08:00
menete
ac91ac1408 add throw on nullptr CTOR test (#577) 2018-02-12 09:31:09 -08:00
Anna Gringauze
3a12c55cb6
Merge pull request #616 from neilmacintosh/tidy-comparison-ops
Tidy up span comparison ops
2018-02-11 22:36:32 -08:00
Anna Gringauze
b446ce9297
Merge pull request #615 from neilmacintosh/remove-move-ops
Remove move ops from span
2018-02-11 22:36:14 -08:00
Anna Gringauze
a03fde29b9
Merge pull request #614 from neilmacintosh/remove-nullptr-t-ctor
Remove from-nullptr_t constructor from span
2018-02-11 22:34:46 -08:00
Neil MacIntosh
533494335b Merge branch 'master' of https://github.com/neilmacintosh/GSL into remove-move-ops 2018-02-11 14:27:05 -08:00
Neil MacIntosh
314065b317 Fix span comparison ops to take arguments by-value rather than by-ref. 2018-02-11 14:22:08 -08:00
Neil MacIntosh
f63fe12ba7 Merge from upstream master. 2018-02-11 13:36:18 -08:00
beinhaerter
3ff6004bc3 added const (#605)
Resolves compiler code analysis warning ...\gsl\include\gsl\string_span(101): warning C26496: The variable 'str_span' is assigned only once, mark it as const (con.4: https://go.microsoft.com/fwlink/p/?LinkID=784969).
2018-02-11 12:19:10 -08:00
Beat Bolli
1a3eb2a6d4 Rename final_act in GSL.natvis (#593)
Commit 6e2e207c8d renamed final_act to final_action. Do this also in
GSL.natvis.
2018-02-11 12:18:00 -08:00
Casey Carter
95da2fd337 Don't use clang's __builtin_assume as an optimizer hint (#608)
Fixes #607.

Drive-by: use '?:' to contextually convert to bool in the fallback definition of `GSL_ASSUME`
2018-02-11 12:16:39 -08:00
Neil MacIntosh
c23d17a61a
Make iterator access functions on span constexpr (#612)
As per feedback on span received during the C++ standardization discussions.
2018-02-10 21:11:08 -08:00
Neil MacIntosh
87e22faa7e
Removed from-smart-ptr constructors. (#611)
As per feedback during standardization discussions.
2018-02-10 20:02:05 -08:00
Neil MacIntosh
5538021e76 Removed unnecessary move operations. 2018-02-10 20:00:44 -08:00
Neil MacIntosh
2bdbba7418 Removed span from-nullptr_t ctor. 2018-02-10 19:21:22 -08:00
Neil MacIntosh
72688ff009 Removed span.length() as synonym for span.size(). 2018-02-10 18:58:28 -08:00
Neil MacIntosh
9ed6ecc4e0 Made all span iterator access functions constexpr. 2018-02-10 18:25:07 -08:00
Neil MacIntosh
028925caba Removed from-smart-ptr constructors. 2018-02-10 18:05:17 -08:00
Neil MacIntosh
64a7dae4c6
Updated README with another build report. 2018-01-23 13:52:05 -08:00
paweldac
9d65e74400 added gsl_algorithm and gsl_byte headers to main gsl header (#594) 2017-12-04 09:18:40 -08:00
paweldac
210cc08a49 Visual Studio Debug Visualizers support (#575)
changes:
    - minimal cmake version updated to 3.7(first version with .natvis file handling)
    - updated cmake version in readme file
    - GSL.natvis file is added only to VS projects
2017-11-28 07:31:06 -08:00
Tiago
6e2e207c8d rename final_act to final_action (#579) 2017-11-28 07:20:32 -08:00
paweldac
436dbad8c6 Remove std::iterator inheritance from multi_span (#591)
In C++17 std::iterator is marked duplicated. Added handwritten usigs for traits.
2017-11-28 07:15:34 -08:00
Tiago
0d33bf6794 Applied iwyu --comment to the code base (#588) 2017-11-28 07:13:49 -08:00
Tiago
1c95f9436e Updates catch to version 2.0 (#580)
Catch 1 would capture exceptions by value and depending on your clang
config could lead to errors/warnings.
2017-11-14 08:44:56 -08:00
bjude
7e529a47c2 Remove #pragma once (#545) (#570)
Core Guidelines SF.8 recommends using portable include guards instead.
2017-11-14 08:38:16 -08:00
menete
2ad93a38dd Iosfwd (#586)
* Solves #567 with <iosfwd> approach

* adds a little testing to not_null ostream
2017-11-14 08:14:20 -08:00
Tiago
d10ebc6555 Drop "Dummy" from enable_if in templates (#572)
Looks like this was here because of MSVC 2013 compat which is not
supported anymore
2017-11-03 16:18:59 -07:00
Anna Gringauze
9a7897915e Minimize checking in subspan (#569)
* rewrite span subspan checks to help optimizations
* Removed checking pointer for null for subspans. We would never
  check pointer for null in between ptr and ptr+size in the
  original span, so there seems to be  no reason to do so for
  subspans, provided that the subspan's boundaries are ensured
  to be within the range of the original span's boundaries.

This change allows to simplify generated code, for example, to
remove 5 out of 9 branches in code generated from the following
by MSVC, and 4 out 8 branches in clang and gcc-generated code:

span<int> mysubspan(int* p, std::ptrdiff_t size, std::ptrdiff_t i)
{
  if (p != nullptr)
  {
    span<int> s = { p, size };
    return s.subspan(i);
  }

  return { nullptr };
}

Similar effects are achieved for dynamic subspans of static spans,
where in the following code we remove 2 out of 4 branchs in MSVC
and GCC-generated code:

int test_dynamic_subspan_of_static_span(std::ptrdiff_t i)
{
  int x[] = { 0,1,2,3,4,5 };
  span<int, 6> s = { x };
  auto subspan = s.subspan(i);
  return subspan.size();
}
2017-11-03 16:13:39 -07:00
Tiago
4862a270b9 Move GSL pointers to a separate header (#566) 2017-10-31 10:19:12 -07:00
menete
1d936eb90c additional span tests (pointer length constructor) (#568) 2017-10-31 10:11:45 -07:00
Tiago
bec7fa72c1 Clean up and update CI build scripts (#563)
* travis.yml clean up

- Remove trailling spaces
- Move notification setting from the bottom to the top
- Set Linux as default OS
- Simplify cache directory
- Add banners around different configurations

* Update CMake installation routine

- Make it depend on variable (easier to update)
- Simplify code a bit

* Re-organize build matrix and LLVM install

- make logic depend on a single COMPILER variable
- Update LLVM installation process

* Update compilers to latest stable version
2017-10-25 11:36:31 -07:00
Casey Carter
211e195d8f Revert inadvertent addition of tests/unittest-cpp submodule from #561 (#562) 2017-10-18 17:56:11 -07:00