Skip to content

Commit 87cc569

Browse files
committed
deploy: fe89cb4
1 parent 9f984cb commit 87cc569

File tree

3 files changed

+79
-55
lines changed

3 files changed

+79
-55
lines changed

cppcon2025/cppcon_2025_slides.html

Lines changed: 65 additions & 54 deletions
Large diffs are not rendered by default.

cppcon2025/cppcon_2025_slides.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,20 @@ void serialize(string_builder& b, const std::set<T>& v) { /* ... */ }
493493
Concepts let us say: **"If it walks like a duck and quacks like a duck..."**
494494
495495
```cpp
496-
// The NEW way - one function handles ALL array-like containers!
496+
template <typename T>
497+
concept container_but_not_string =
498+
requires(T a) {
499+
{ a.size() } -> std::convertible_to<std::size_t>;
500+
{
501+
a[std::declval<std::size_t>()]
502+
}; // check if elements are accessible for the subscript operator
503+
} && !std::is_same_v<T, std::string> &&
504+
!std::is_same_v<T, std::string_view> && !std::is_same_v<T, const char *>;
505+
```
506+
507+
---
508+
509+
```cpp
497510
template<typename T>
498511
requires(has_size_and_subscript<T>) // "If it has .size() and operator[]"
499512
void serialize(string_builder& b, const T& container) {

cppcon2025/cppcon_2025_slides.pdf

3.34 KB
Binary file not shown.

0 commit comments

Comments
 (0)