vendredi 27 mai 2016

Where does "::value" get its value?

I've been reading up about SFINAE and see some examples with some variant of the following:

#include <iostream>
#include <type_traits>

template <typename... Ts> using void_t = void;

template <typename T, typename = void>
struct has_typedef_foobar : std::false_type {};

template <typename T>
struct has_typedef_foobar<T, void_t<typename T::foobar>> : std::true_type {};

struct foo {
  using foobar = float;
};

int main() {
  std::cout << std::boolalpha;
  std::cout << has_typedef_foobar<int>::value << std::endl;
  std::cout << has_typedef_foobar<foo>::value << std::endl;
}

(Taken from http://ift.tt/1dG3Q9f)

I'm confused as to where the value member comes from. Both definitions of has_typedef_foobar don't seem to specify a boolean member named value.

Where does ::value get its value? I suspect it's some kind of compiler-provided value and would like to read up about it, but I'm not sure what term to google since my queries have brought up other C++11-related value-related topics.

Thanks.

Aucun commentaire:

Enregistrer un commentaire