Questions tagged [tag-dispatching]
11 questions
12
votes
2 answers
Using enum instead of struct for tag dispatching in C++
Let's take implementation of the std::unique_lock from the Standard Library:
struct defer_lock_t { explicit defer_lock_t() = default; };
struct try_to_lock_t { explicit try_to_lock_t() = default; };
struct adopt_lock_t { explicit adopt_lock_t() =…

Super-intelligent Shade
- 5,932
- 23
- 46
7
votes
1 answer
Difference between SFINAE and tag dispatch
In this video https://youtu.be/Vkck4EU2lOU?t=582 "tag dispatch" and SFINAE are being presented as the alternatives, allowing to achieve selection of the desired template function.
Is it correct? Isn't "tag dispatch" using SFINAE?
If it's correct,…

user2449761
- 1,169
- 13
- 25
2
votes
1 answer
Using enum class values in constexpr branches
the code below prints val2 on both f() calls. What would be a proper way to execute specific branch in f() based on enum value ?
enum class E
{
val1,
val2
};
using val1_t = std::integral_constant;
using val2_t =…

psb
- 342
- 3
- 12
2
votes
2 answers
C++ Template "if constexpr" into the old "Tag Dispatching" method
I'm pretty new to template concepts like SFINAE or tag dispatching and been reading some articles and examples about it that didn't help me getting to my approach. So I would really appreciate if someone can help please.
My goal is to have 1 single…
user7867434
1
vote
0 answers
Shortest syntax for type tag lambda dispatch in C++ 17
I am restrained to use C++17 and I want to pass a type to a lambda by passing in a type tag, which I can in the following way in C++ 20 and C++17.
template
struct Type
{
using type = T;
};
auto lambda20 = [](Type){
…

Andreas Loanjoe
- 2,205
- 10
- 26
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
Tag dispatching with transformed `boost::mpl::vector`s
I am trying to tag-dispatch into a function with a reversed copy of a boost::mpl::vector:
using InitOrder = boost::mpl::vector<
struct Foo,
struct Bar,
struct Baz
>;
template
void…

Quentin
- 62,093
- 7
- 131
- 191
0
votes
1 answer
Android NFC - Not getting Tag information using Application Record (AAR)
I am trying to read NFC tag (NfcA) when app is in background using Android Application Record (AAR). When Tag is being discovered, my app is getting open although it is not delivering Tag info in an activity.
Also it is alwasy opening Launcher…

silwar
- 6,470
- 3
- 46
- 66
0
votes
1 answer
tag dispatch based on conditional_t over is_floating_point
I am getting a strange, Call to function 'Equals' that is neither visible in the template definition nor found by argument-dependent lookup, for a simple tag dispatch implementation.
template
bool Equals(T lhs, T rhs){
return…

Atta Oveisi
- 21
- 2
- 8
0
votes
2 answers
Variadic templates for multiple heritage assertions - "...redeclared with 3 template parameters..."
I am trying to implement my own std::is_base_of for my AVR programming (avr-gcc does not yet support . I took inspiration of the possible implementation on the cppreference page, it worked for a single type check. However, what I want…

Smartskaft2
- 468
- 3
- 16
0
votes
3 answers
How can I get this dispatching call to work?
I am trying to familiarize myself with object orientation In Ada. Your site helped me with another O-O problem a couple of months ago and I hope that you will be willing to help again.
The situation: I have an abstract type “token” and 2 derived…

CharlesBrown
- 1
- 1