Questions tagged [customization-point]
11 questions
16
votes
2 answers
Why is deleting a function necessary when you're defining customization point object?
From libstdc++ header:
namespace ranges
{
namespace __cust_swap
{
template void swap(_Tp&, _Tp&) = delete;
From MS-STL header:
namespace ranges {
namespace _Swap {
template

Lewis Liman
- 523
- 5
- 9
9
votes
3 answers
Why is std::swap not using swap idiom?
As proper use of std::swap is:
using std::swap;
swap(a,b);
It is a bit verbose but it makes sure that if a,b have better swap defined it gets picked.
So now my question is why std::swap is not implemented using this technique so user code would…

NoSenseEtAl
- 28,205
- 28
- 128
- 277
3
votes
1 answer
customisation point for alias to std types
Let's say I am writing some generic algorithm in lib namespace that calls a customisation point my_func.
First attempt is using ADL for my_func
one of the user wants to specialise my_func for his type, which is an alias to std type. Surely define it…

Hui
- 571
- 1
- 3
- 9
3
votes
1 answer
hidden friend in a class template name clashes with another symbol in inline namespace
I'd like to provide a hidden friend for my type, and at the same time there is another object with the same name in an inline namespace. Everything works fine with normal types.
But if I have a template, the compiler errors when I instantiate the…

Hui
- 571
- 1
- 3
- 9
2
votes
1 answer
c++ customization point object pattern. Argument and customization in different namespaces
I recently learned about customization point object pattern and tried implementing it. At first, it looked like a very good way to make some base functionality and extend it on different types.
In examples below I use Visual Studio 2022 with c++20…

smidimir
- 23
- 4
2
votes
2 answers
Why isn't `std::hash` a customization point by overload as `std::begin`?
As the title says, std::begin, std::end, std::swap, etc, are very well known std "customization points" (functions meant to be found by ADL). However, std::hash is, I think, the only std behaviour customizable by the user that implies to (A) open…

ABu
- 10,423
- 6
- 52
- 103
1
vote
0 answers
Fix or alternative to ADL when one of the functions is actually a function object
In the following code, the standalone component in the namespace S has its own definitions of Big and Small types, together with a split function to split one Big into a collection of the Smalls.
S also provides another function, work, which makes…

Enlico
- 23,259
- 6
- 48
- 102
1
vote
1 answer
What is required for a custom BGL graph to work with topological sort?
I've created a custom BGL graph model, like in this answer: What is needed to use BGL algorithms on existing data structures ( edges and vertices as vector

bosmacs
- 7,341
- 4
- 31
- 31
1
vote
2 answers
How to deal gracefully with customization points of algorithms as well as constraints on their arguments?
As an example, let's take the following algorithm for computing the longest common subsequence of two sequences, copied from Rosetta Code:
longest xs ys = if length xs > length ys then xs else ys
lcs [] _ = []
lcs _ [] = []
lcs (x:xs) (y:ys)
|…

Enlico
- 23,259
- 6
- 48
- 102
0
votes
1 answer
Is it a disadvantage to have "names" coupled due to custom point objects?
As we know, the CPO can use concepts to check the performance requirements(like input type, output type, etc.) of the user-defined function reload that it found. But they can't check the semantics of the user's function, right? Like the following…

zclll
- 77
- 7
0
votes
0 answers
Why can we customize ctors & dtors but not accessors?
(This is not a question about overloading operator. in general.)
We know that there are many good reasons to use setter and getter methods.
Well, then, it seems strange to me these are not customization points of member access i.e. if class A has a…

einpoklum
- 118,144
- 57
- 340
- 684