Questions tagged [detection-idiom]

The C++ detection idiom a programming pattern for detecting valid usages of types. It was introduced in WG21 document N4436 and will be part of the C++17 standard library.

A full description of the idiom can be found in WG21 N4436.

8 questions
5
votes
0 answers

Detecting whether or not a callable object is binary (including generic constrained lambdas)

I'm trying to detect whether or not a callable object is binary (i.e. if its operator() takes two arguments). I want to perform this check on lambdas, including generic lambdas and constrained generic lambdas (e.g. with trailing std::enable_if_t…
Vittorio Romeo
  • 90,666
  • 33
  • 258
  • 416
4
votes
3 answers

Counting arguments of an arbitrary callable with the C++ detection idiom

I've been using the C++ detection idiom create a metafunction for determining the number of arguments to an arbitrary callable. So far, I have this (full, compilable code at http://ideone.com/BcgDhv): static constexpr auto max_num_args =…
Daisy Sophia Hollman
  • 6,046
  • 6
  • 24
  • 35
3
votes
0 answers

Is possible to write a trait to detect a friend class declaration?

I would like to know if it is possible to write a trait capable to detect a friend class declaration. I'm particularly interested in the case of forward declaration, like so: struct Baz { friend struct Foo; }; struct Foo {}; Please no Boost or…
2
votes
0 answers

why does type_identity break the implementation of is_detected

p0887r1: 2.3 Fundamental metafunction building block There are two ubiquitous idioms for type traits: define a public data member value with a given value define a public member typedef type that names a given type It is surprising that there is…
Chen Li
  • 4,824
  • 3
  • 28
  • 55
1
vote
1 answer

SFINAE to detect operation when it is forbidden to call with temporary

It is possible to use the following pattern to detect whether or not x can be applied to T template struct CanDoX: std::false_type{}; template struct CanDoX
user877329
  • 6,717
  • 8
  • 46
  • 88
0
votes
0 answers

Emulating template constraints in C++14

I'm coding in C++14 a program that uses template classes and functions. I don't like the compiler error messages I get when the template types don't fulfill the requirements I ask for with std::enable_if I wondered if I could do better trying to…
0
votes
0 answers

Problem with using OnIdiom on VS for Mac using Xamarin Forms

I have always used this the same way and it always worked. After an update I keep getting an error. Can someone help me out? This is the error I get.
0
votes
2 answers

OnIdiom for Grid columnspan

I need to use OnIdiom for grid column definition, but it isn't working. See my code below. Can anyone tell me what I am doing wrong and suggest a solution?
Riyas
  • 475
  • 1
  • 8
  • 27