Concept Maps using C++23 Library Tech - Indirection to APIs for a Concept - Steve Downey - C++Now 24

  Рет қаралды 1,977

CppNow

CppNow

Күн бұрын

www.cppnow.org
---
Concept Maps using C++23 Library Tech - Indirection to APIs for a Concept - Steve Downey - C++Now 2024
---
C++0x Concepts included a feature called "Concept Maps," which allowed a set of functions, types, and template definitions to be associated with a concept and the map to be specialized for types that meet that concept. This allowed for open extension of a concept. A definition could be provided that allows an algorithm to operate in terms of the API that concept presents, and the map would then define how those operations are implemented for a particular type. This is similar to how typeclasses work in Haskell.
The feature was very general, and was lost as part of the Concepts-Lite proposal that was eventually adopted. This loss of a level of indirection means that the APIs for a concept must be implemented by those names for a type, even when those names are not particularly good choices in the natural domain of a type rather than in the domain as a concept. The proliferation of transform functions for a functorial map is such a problem. It is also a problem when adapting types that are closed for extension or do not permit member functions.
In this talk, I will demonstrate a technique using inline variable templates that deliver many of the benefits of concept maps -- at the cost of some syntactic noise in the use in algorithms -- and some advanced machinery which allows minimal definitions of a basis set of operations that can be used to implement the rest of the map. In particular, we will discuss using deducing this (P0847) in addition to -- not as a replacement for -- the Curiously Recurring Template Pattern, which allows syntactically checked definitions of the minimal basis set.
To make the technique concrete, I will present a simple binary tree data structure that uses tags to classify the nodes. The tags are required to model the monoid concept, which requires that the tag type have a binary operation and an instance that is an identity for that operation. Integers with the identity element 0 and the operation plus form a monoid. Using different operations and identity elements, the tree can represent a data structure that provides sequenced indexed access - like std::vector or std::deque, a priority queue - like std::priority_queue, or searchability - like std::map, without changes to the core data structure. The binary tree operations are modeled after the more complicated fingertree data structure, which shares the flexible characteristics provided by tags with much greater efficiency.
---
Slides: github.com/boo...
---
Steve Downey
Steve Downey has been a programmer for more than 30 years. Steve graduated from SUNY Purchase with a BS in Mathematics. A Computer Science degree would have involved two classes before 11:00 am, so was impossible.
He has worked at Bloomberg since 2003, and is currently working as an Engineer on the C++ Infrastructure team.
---
C++Now 2025 - 28th April - 2nd May
C++Now is an annual onsite international C++ programming and coding conference held in Aspen, Colarado. For all C++ developers, C++ software engineers and those involved with the C++ language, CppNow provides an indepth and technical content provided by the best and brightest C++ experts of the C++ world.
Annual CppNow Conference - www.cppnow.org
/ cppnow
/ cppnow
/ cppnow
/ cppnow
mastodon.socia...
Video Sponsors: millennium and think-cell
---
Videos Filmed & Edited By Bash Films: bashfilms.com/
KZbin Channel Managed & Optimized By Digital Medium Ltd: events.digital...
---
#boost #cpp #cplusplusprogramming #codingconcepts #cppprogramming

Пікірлер
@Roibarkan
@Roibarkan 3 ай бұрын
1:01:38 🤓technically, the identity element for ‘MinMonoid’ is the numeric_limits::max()
@AlfredoCorrea
@AlfredoCorrea 3 ай бұрын
Not just technically. (but, it can be also be ::infinity depending on the domain of your problem)
@alskidan
@alskidan 3 ай бұрын
I'm surprised to see Rust traits as the prime example for concept maps. Swift protocol conformance extensions ARE the actual implementation of C++11 concept maps.
@abhinavk0929
@abhinavk0929 3 ай бұрын
yep, the same guys behind C++0x proposals for concept maps worked on Swift too.
@syntaxed2
@syntaxed2 3 ай бұрын
Why is modern c++ so unreadable? - It doesnt even look like C++
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 45 МЛН
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
C can do this too and it's faster than Python
2:09:48
Tsoding Daily
Рет қаралды 15 М.
Jeff Dean: AI will Reshape Chip Design - NeurIPS 2024
43:53
GradientSpills
Рет қаралды 6 М.
The C++ Vector Challenge - Lisa Lippincott - C++Now 2024
1:30:30
Eigenvector differentiation
1:26:35
Jonathan Gross
Рет қаралды 1
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 45 МЛН