Skip to content

Commit c722e62

Browse files
committed
upgrade to cxcm v1.1.1 -- make assignment operator only work on lvalues for where it makes sense
1 parent 87eee9b commit c722e62

File tree

4 files changed

+75
-47
lines changed

4 files changed

+75
-47
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
**dsga** is a single header-only **c++20 library** that implements the **vectors** and **matrices** from the OpenGL Shading Language 4.6 specification ([pdf](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.60.pdf) | [html](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.html)). It is inspired by the spec, but does deviate in some small ways, mostly to make it work well in c++20. It is not intended to be used for rendering, just for sharing the fundamental data structures and associated functions. Our requirements in general are for things like 3D CAD/CAM applications and other geometric and algebraic things. See [motivation](docs/MOTIVATION.md) for more details. This library does not use SIMD instructions or types under the hood, beyond whatever the compiler provides through optimization.
44

55
## Current Version
6-
v1.3.11
6+
v1.3.12
77

88
## Contents
99
* [Some Quick Examples](#some-quick-examples)
@@ -278,7 +278,7 @@ This is a c++20 library, so that needs to be the minimum standard that you tell
278278
279279
## Status
280280
281-
Current version: `v1.3.11`
281+
Current version: `v1.3.12`
282282
283283
* Everything major has some tests, but code coverage is not 100%.
284284
* [Last Released: v1.3.0](https://github.com/davidbrowne/dsga/releases/tag/v1.3.0)
@@ -306,14 +306,14 @@ The tests have been most recently run on:
306306
307307
### Windows 11 Native
308308
309-
* **MSVC 2022 - v17.8.3**
309+
* **MSVC 2022 - v17.8.5**
310310
311311
```
312312
[doctest] doctest version is "2.4.11"
313313
[doctest] run with "--help" for options
314314
===============================================================================
315315
[doctest] test cases: 109 | 109 passed | 0 failed | 0 skipped
316-
[doctest] assertions: 2135 | 2135 passed | 0 failed |
316+
[doctest] assertions: 2159 | 2159 passed | 0 failed |
317317
[doctest] Status: SUCCESS!
318318
```
319319
@@ -324,7 +324,7 @@ The tests have been most recently run on:
324324
[doctest] run with "--help" for options
325325
===============================================================================
326326
[doctest] test cases: 109 | 109 passed | 0 failed | 0 skipped
327-
[doctest] assertions: 2135 | 2135 passed | 0 failed |
327+
[doctest] assertions: 2159 | 2159 passed | 0 failed |
328328
[doctest] Status: SUCCESS!
329329
```
330330
@@ -337,7 +337,7 @@ Performs all the unit tests except where there is lack of support for ```std::is
337337
[doctest] run with "--help" for options
338338
===============================================================================
339339
[doctest] test cases: 109 | 109 passed | 0 failed | 0 skipped
340-
[doctest] assertions: 2119 | 2119 passed | 0 failed |
340+
[doctest] assertions: 2143 | 2143 passed | 0 failed |
341341
[doctest] Status: SUCCESS!
342342
```
343343
@@ -350,7 +350,7 @@ Performs all the unit tests except where there is lack of support for ```std::is
350350
[doctest] run with "--help" for options
351351
===============================================================================
352352
[doctest] test cases: 109 | 109 passed | 0 failed | 0 skipped
353-
[doctest] assertions: 2135 | 2135 passed | 0 failed |
353+
[doctest] assertions: 2159 | 2159 passed | 0 failed |
354354
[doctest] Status: SUCCESS!
355355
```
356356
@@ -363,7 +363,7 @@ Performs all the unit tests except where there is lack of support for ```std::is
363363
[doctest] run with "--help" for options
364364
===============================================================================
365365
[doctest] test cases: 109 | 109 passed | 0 failed | 0 skipped
366-
[doctest] assertions: 2119 | 2119 passed | 0 failed |
366+
[doctest] assertions: 2143 | 2143 passed | 0 failed |
367367
[doctest] Status: SUCCESS!
368368
```
369369
@@ -376,7 +376,7 @@ Performs all the unit tests except where there is lack of support for ```std::is
376376
[doctest] run with "--help" for options
377377
===============================================================================
378378
[doctest] test cases: 109 | 109 passed | 0 failed | 0 skipped
379-
[doctest] assertions: 2135 | 2135 passed | 0 failed |
379+
[doctest] assertions: 2159 | 2159 passed | 0 failed |
380380
[doctest] Status: SUCCESS!
381381
```
382382
@@ -389,7 +389,7 @@ Performs all the unit tests except where there is lack of support for ```std::is
389389
[doctest] run with "--help" for options
390390
===============================================================================
391391
[doctest] test cases: 109 | 109 passed | 0 failed | 0 skipped
392-
[doctest] assertions: 2119 | 2119 passed | 0 failed |
392+
[doctest] assertions: 2143 | 2143 passed | 0 failed |
393393
[doctest] Status: SUCCESS!
394394
```
395395

docs/API.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ template <typename UnOp>
581581
requires (std::same_as<T, std::invoke_result_t<UnOp, T>> || std::same_as<T, std::invoke_result_t<UnOp, const T &>>)
582582
[[nodiscard]] constexpr basic_vector<T, Count> apply(UnOp op) const noexcept;
583583
```
584-
Applies a lambda/function/function object/callable to every element of a vector. The callable must take either a ```T``` or ```const T &```, and it must return a ```T```. Returns a vector of the results.
584+
Applies a lambda/function/function object/callable to every element of a vector, in an unspecified order. The callable must take either a ```T``` or ```const T &```, and it must return a ```T```. Returns a vector of the results.
585585

586586
##### ```vector_base::shift```
587587
```c++
@@ -690,9 +690,9 @@ Data access through the indexing operator. The indexing operator already takes t
690690
```c++
691691
template <bool W, dimensional_scalar U, typename D>
692692
requires Writable && implicitly_convertible_to<U, T>
693-
constexpr indexed_vector &operator =(const vector_base<W, U, Count, D> &other) noexcept;
693+
constexpr indexed_vector &operator =(const vector_base<W, U, Count, D> &other) & noexcept;
694694
```
695-
The assignment operator. It can be assigned from objects that inherit from ```vector_base```.
695+
The assignment operator. It can be assigned from objects that inherit from ```vector_base```. Can assign only to lvalues.
696696

697697
##### ```indexed_vector::data```
698698
```c++
@@ -927,9 +927,9 @@ Data access through the indexing operator. The indexing operator already takes t
927927
```c++
928928
template <bool W, dimensional_scalar U, typename D>
929929
requires Writable && implicitly_convertible_to<U, T>
930-
constexpr basic_vector &operator =(const vector_base<W, U, Count, D> &other) noexcept;
930+
constexpr basic_vector &operator =(const vector_base<W, U, Count, D> &other) & noexcept;
931931
```
932-
The assignment operator. It can be assigned from objects that inherit from ```vector_base```.
932+
The assignment operator. It can be assigned from objects that inherit from ```vector_base```. Can assign only to lvalues.
933933

934934
##### ```basic_vector::data```
935935
```c++
@@ -1138,9 +1138,9 @@ Data access through the indexing operator.
11381138
```c++
11391139
template <floating_point_scalar U>
11401140
requires implicitly_convertible_to<U, T>
1141-
constexpr basic_matrix &operator =(const basic_matrix<U, C, R> &other) noexcept;
1141+
constexpr basic_matrix &operator =(const basic_matrix<U, C, R> &other) & noexcept;
11421142
```
1143-
The assignment operator.
1143+
The assignment operator. Can assign only to lvalues.
11441144

11451145
##### ```basic_matrix::data```
11461146
```c++

include/dsga.hxx

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ inline void cxcm_constexpr_assert_failed(Assert &&a) noexcept
9696

9797
constexpr inline int DSGA_MAJOR_VERSION = 1;
9898
constexpr inline int DSGA_MINOR_VERSION = 3;
99-
constexpr inline int DSGA_PATCH_VERSION = 11;
99+
constexpr inline int DSGA_PATCH_VERSION = 12;
100100

101101
namespace dsga
102102
{
@@ -111,7 +111,7 @@ namespace dsga
111111

112112
constexpr inline int CXCM_MAJOR_VERSION = 1;
113113
constexpr inline int CXCM_MINOR_VERSION = 1;
114-
constexpr inline int CXCM_PATCH_VERSION = 0;
114+
constexpr inline int CXCM_PATCH_VERSION = 1;
115115

116116
namespace dd_real
117117
{
@@ -476,13 +476,13 @@ namespace dsga
476476

477477
// undefined behavior if value is std::numeric_limits<T>::min()
478478
template <std::signed_integral T>
479-
constexpr double abs(T value) noexcept
479+
constexpr T abs(T value) noexcept
480480
{
481481
return (value < T(0)) ? -value : value;
482482
}
483483

484484
template <std::unsigned_integral T>
485-
constexpr double abs(T value) noexcept
485+
constexpr T abs(T value) noexcept
486486
{
487487
return value;
488488
}
@@ -1222,7 +1222,7 @@ namespace dsga
12221222
// don't know what to do if someone tries to negate the most negative number.
12231223
// standard says behavior is undefined if you can't represent the result by return type.
12241224
template <std::integral T>
1225-
constexpr double abs(T value) noexcept
1225+
constexpr T abs(T value) noexcept
12261226
{
12271227
cxcm_constexpr_assert(value != std::numeric_limits<T>::min(), "undefined behavior in abs()");
12281228

@@ -1925,13 +1925,13 @@ namespace dsga
19251925
auto copy = basic_vector<T, Count>(*this);
19261926
if (by > 0)
19271927
{
1928-
int count = by > max_val ? max_val : by;
1928+
int count = by;
19291929
std::ranges::rotate(copy, copy.begin() + count);
19301930
}
19311931
else if (by < 0)
19321932
{
1933-
int count = -by > max_val ? max_val : -by;
1934-
std::ranges::rotate(copy, copy.begin() + max_val - count);
1933+
int count = -by;
1934+
std::ranges::rotate(copy, copy.begin() + (max_val - count));
19351935
}
19361936

19371937
return copy;
@@ -2033,8 +2033,8 @@ namespace dsga
20332033
constexpr indexed_vector_const_iterator() noexcept = default;
20342034
constexpr indexed_vector_const_iterator(const indexed_vector_const_iterator &) noexcept = default;
20352035
constexpr indexed_vector_const_iterator(indexed_vector_const_iterator &&) noexcept = default;
2036-
constexpr indexed_vector_const_iterator &operator =(const indexed_vector_const_iterator &) noexcept = default;
2037-
constexpr indexed_vector_const_iterator &operator =(indexed_vector_const_iterator &&) noexcept = default;
2036+
constexpr indexed_vector_const_iterator &operator =(const indexed_vector_const_iterator &) & noexcept = default;
2037+
constexpr indexed_vector_const_iterator &operator =(indexed_vector_const_iterator &&) & noexcept = default;
20382038
constexpr ~indexed_vector_const_iterator() = default;
20392039

20402040
[[nodiscard]] constexpr reference operator *() const noexcept
@@ -2179,8 +2179,8 @@ namespace dsga
21792179
constexpr indexed_vector_iterator() noexcept = default;
21802180
constexpr indexed_vector_iterator(const indexed_vector_iterator &) noexcept = default;
21812181
constexpr indexed_vector_iterator(indexed_vector_iterator &&) noexcept = default;
2182-
constexpr indexed_vector_iterator &operator =(const indexed_vector_iterator &) noexcept = default;
2183-
constexpr indexed_vector_iterator &operator =(indexed_vector_iterator &&) noexcept = default;
2182+
constexpr indexed_vector_iterator &operator =(const indexed_vector_iterator &) & noexcept = default;
2183+
constexpr indexed_vector_iterator &operator =(indexed_vector_iterator &&) & noexcept = default;
21842184
constexpr ~indexed_vector_iterator() = default;
21852185

21862186
[[nodiscard]] constexpr reference operator *() const noexcept
@@ -2296,7 +2296,7 @@ namespace dsga
22962296
// copy assignment
22972297
template <bool W, dimensional_scalar U, typename D>
22982298
requires Writable && implicitly_convertible_to<U, T>
2299-
constexpr indexed_vector &operator =(const vector_base<W, U, Count, D> &other) noexcept
2299+
constexpr indexed_vector &operator =(const vector_base<W, U, Count, D> &other) & noexcept
23002300
{
23012301
[&]<std::size_t ...Js>(std::index_sequence<Js ...>) noexcept
23022302
{
@@ -2310,7 +2310,7 @@ namespace dsga
23102310
// assignment for some scalar type that converts to T and is only for indexed_vector of [Count == 1]
23112311
template <dimensional_scalar U>
23122312
requires Writable && implicitly_convertible_to<U, T> && (Count == 1)
2313-
constexpr indexed_vector &operator =(U other) noexcept
2313+
constexpr indexed_vector &operator =(U other) & noexcept
23142314
{
23152315
set(other);
23162316

@@ -2685,8 +2685,8 @@ namespace dsga
26852685

26862686
constexpr basic_vector(const basic_vector &) noexcept = default;
26872687
constexpr basic_vector(basic_vector &&) noexcept = default;
2688-
constexpr basic_vector &operator =(const basic_vector &) noexcept = default;
2689-
constexpr basic_vector &operator =(basic_vector &&) noexcept = default;
2688+
constexpr basic_vector &operator =(const basic_vector &) & noexcept = default;
2689+
constexpr basic_vector &operator =(basic_vector &&) & noexcept = default;
26902690

26912691
//
26922692
// constructors
@@ -2725,15 +2725,15 @@ namespace dsga
27252725

27262726
template <bool W, dimensional_scalar U, typename D>
27272727
requires Writable && implicitly_convertible_to<U, T>
2728-
constexpr basic_vector &operator =(const vector_base<W, U, Count, D> &other) noexcept
2728+
constexpr basic_vector &operator =(const vector_base<W, U, Count, D> &other) & noexcept
27292729
{
27302730
set(other[0]);
27312731
return *this;
27322732
}
27332733

27342734
template <typename U>
27352735
requires Writable && implicitly_convertible_to<U, T>
2736-
constexpr basic_vector &operator =(U value) noexcept
2736+
constexpr basic_vector &operator =(U value) & noexcept
27372737
{
27382738
set(value);
27392739
return *this;
@@ -2884,8 +2884,8 @@ namespace dsga
28842884

28852885
constexpr basic_vector(const basic_vector &) noexcept = default;
28862886
constexpr basic_vector(basic_vector &&) noexcept = default;
2887-
constexpr basic_vector &operator =(const basic_vector &) noexcept = default;
2888-
constexpr basic_vector &operator =(basic_vector &&) noexcept = default;
2887+
constexpr basic_vector &operator =(const basic_vector &) & noexcept = default;
2888+
constexpr basic_vector &operator =(basic_vector &&) & noexcept = default;
28892889

28902890
//
28912891
// constructors
@@ -2931,7 +2931,7 @@ namespace dsga
29312931

29322932
template <bool W, dimensional_scalar U, typename D>
29332933
requires Writable && implicitly_convertible_to<U, T>
2934-
constexpr basic_vector &operator =(const vector_base<W, U, Count, D> &other) noexcept
2934+
constexpr basic_vector &operator =(const vector_base<W, U, Count, D> &other) & noexcept
29352935
{
29362936
set(other[0], other[1]);
29372937
return *this;
@@ -3158,8 +3158,8 @@ namespace dsga
31583158

31593159
constexpr basic_vector(const basic_vector &) noexcept = default;
31603160
constexpr basic_vector(basic_vector &&) noexcept = default;
3161-
constexpr basic_vector &operator =(const basic_vector &) noexcept = default;
3162-
constexpr basic_vector &operator =(basic_vector &&) noexcept = default;
3161+
constexpr basic_vector &operator =(const basic_vector &) & noexcept = default;
3162+
constexpr basic_vector &operator =(basic_vector &&) & noexcept = default;
31633163

31643164
//
31653165
// constructors
@@ -3207,7 +3207,7 @@ namespace dsga
32073207

32083208
template <bool W, dimensional_scalar U, typename D>
32093209
requires Writable && implicitly_convertible_to<U, T>
3210-
constexpr basic_vector &operator =(const vector_base<W, U, Count, D> &other) noexcept
3210+
constexpr basic_vector &operator =(const vector_base<W, U, Count, D> &other) & noexcept
32113211
{
32123212
set(other[0], other[1], other[2]);
32133213
return *this;
@@ -3654,8 +3654,8 @@ namespace dsga
36543654

36553655
constexpr basic_vector(const basic_vector &) noexcept = default;
36563656
constexpr basic_vector(basic_vector &&) noexcept = default;
3657-
constexpr basic_vector &operator =(const basic_vector &) noexcept = default;
3658-
constexpr basic_vector &operator =(basic_vector &&) noexcept = default;
3657+
constexpr basic_vector &operator =(const basic_vector &) & noexcept = default;
3658+
constexpr basic_vector &operator =(basic_vector &&) & noexcept = default;
36593659

36603660
//
36613661
// constructors
@@ -3706,7 +3706,7 @@ namespace dsga
37063706

37073707
template <bool W, dimensional_scalar U, typename D>
37083708
requires Writable && implicitly_convertible_to<U, T>
3709-
constexpr basic_vector &operator =(const vector_base<W, U, Count, D> &other) noexcept
3709+
constexpr basic_vector &operator =(const vector_base<W, U, Count, D> &other) & noexcept
37103710
{
37113711
set(other[0], other[1], other[2], other[3]);
37123712
return *this;
@@ -6132,8 +6132,8 @@ namespace dsga
61326132

61336133
constexpr basic_matrix(const basic_matrix &) noexcept = default;
61346134
constexpr basic_matrix(basic_matrix &&) noexcept = default;
6135-
constexpr basic_matrix &operator =(const basic_matrix &) noexcept = default;
6136-
constexpr basic_matrix &operator =(basic_matrix &&) noexcept = default;
6135+
constexpr basic_matrix &operator =(const basic_matrix &) & noexcept = default;
6136+
constexpr basic_matrix &operator =(basic_matrix &&) & noexcept = default;
61376137

61386138
//
61396139
// constructors
@@ -6236,7 +6236,7 @@ namespace dsga
62366236

62376237
template <floating_point_scalar U>
62386238
requires implicitly_convertible_to<U, T>
6239-
constexpr basic_matrix &operator =(const basic_matrix<U, C, R> &other) noexcept
6239+
constexpr basic_matrix &operator =(const basic_matrix<U, C, R> &other) & noexcept
62406240
{
62416241
[&]<std::size_t ...Is>(std::index_sequence<Is...>) noexcept
62426242
{

0 commit comments

Comments
 (0)