Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cpp-shots
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iwr
cpp-shots
Commits
d030f611
Commit
d030f611
authored
8 years ago
by
Praetorius, Simon
Browse files
Options
Downloads
Patches
Plain Diff
small corrections in slides
parent
3404251f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
vortrag_06-07/concepts.html
+10
-9
10 additions, 9 deletions
vortrag_06-07/concepts.html
with
10 additions
and
9 deletions
vortrag_06-07/concepts.html
+
10
−
9
View file @
d030f611
...
@@ -33,7 +33,7 @@ Simon Praetorius *simon.praetorius@tu-dresden.de*
...
@@ -33,7 +33,7 @@ Simon Praetorius *simon.praetorius@tu-dresden.de*
# Motivating Examples
# Motivating Examples
```
```
auto super_cool_function()
;
// Return type?
auto super_cool_function()
{ ... }
// Return type?
template
<class
T
>
template
<class
T
>
void another_cool_function(T const
&
arg); // allowed argument types?
void another_cool_function(T const
&
arg); // allowed argument types?
...
@@ -245,7 +245,7 @@ void advance(I& i, Difference_type<I> n) {
...
@@ -245,7 +245,7 @@ void advance(I& i, Difference_type<I> n) {
```
```
template
<class
T0
,
class
T1
>
template
<class
T0
,
class
T1
>
auto gcd(T0 a, T1 b)
auto gcd(T0 a, T1 b)
{ ... }
```
```
- Input-type? Return-type?
- Input-type? Return-type?
...
@@ -255,7 +255,7 @@ auto gcd(T0 a, T1 b)
...
@@ -255,7 +255,7 @@ auto gcd(T0 a, T1 b)
- Better: constrain the types:
- Better: constrain the types:
```
```
Integer gcd(Integer a, Integer b)
;
Integer gcd(Integer a, Integer b)
{ ... }
```
```
- where `Integer` is a constraint.
- where `Integer` is a constraint.
...
@@ -275,13 +275,13 @@ Integer result = gcd(153, 957);
...
@@ -275,13 +275,13 @@ Integer result = gcd(153, 957);
```
```
template
<Integer
I
,
Integer
J
>
template
<Integer
I
,
Integer
J
>
auto gcd(I a, J b)
;
auto gcd(I a, J b)
{ ... }
```
```
- Or write constraints instead of types directly:
- Or write constraints instead of types directly:
```
```
auto gcd(Integer a, Integer b)
;
auto gcd(Integer a, Integer b)
{ ... }
```
```
- Or write **requires-statement**
- Or write **requires-statement**
...
@@ -289,7 +289,7 @@ auto gcd(Integer a, Integer b);
...
@@ -289,7 +289,7 @@ auto gcd(Integer a, Integer b);
```
```
template
<class
T0
,
class
T1
>
template
<class
T0
,
class
T1
>
requires Integer
<T0>
()
&&
Integer
<T1>
()
requires Integer
<T0>
()
&&
Integer
<T1>
()
auto gcd(T0 a, T1 b)
;
auto gcd(T0 a, T1 b)
{ ... }
```
```
---
---
...
@@ -328,9 +328,10 @@ note: candidate: auto Map<R>::operator[](std::size_t) const
...
@@ -328,9 +328,10 @@ note: candidate: auto Map<R>::operator[](std::size_t) const
auto operator[](std::size_t i) const
auto operator[](std::size_t i) const
^~~~~~~~
^~~~~~~~
note: constraints not satisfied
note: constraints not satisfied
note: within 'template
<class
R
>
concept bool RandomAccessible() [with R = std::__cxx11::list
<int>
]'
note: within 'template
<class
R
>
concept bool RandomAccessible()
concept bool RandomAccessible() {
[with R = std::__cxx11::list
<int>
]'
^~~~~~~~~~~~~~~~
concept bool RandomAccessible() {
^~~~~~~~~~~~~~~~
note: with 'std::__cxx11::list
<int>
range'
note: with 'std::__cxx11::list
<int>
range'
note: with 'std::size_t i'
note: with 'std::size_t i'
note: the required expression 'range[i]' would be ill-formed
note: the required expression 'range[i]' would be ill-formed
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment