Commit Graph

76 Commits

Author SHA1 Message Date
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
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
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
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
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
Tiago
0d33bf6794 Applied iwyu --comment to the code base (#588) 2017-11-28 07:13:49 -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
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
Anna Gringauze
e7bcdf541b Enable vectorization of common loops using iterators with range checking enabled with GCC and Clang (#557) 2017-09-18 15:16:23 -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
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
Casey Carter
3819df6e37 Properly qualify std::size_t (#448) 2017-02-13 12:11:45 -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