Skip to content
Snippets Groups Projects
Commit d030f611 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

small corrections in slides

parent 3404251f
No related branches found
No related tags found
No related merge requests found
...@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment