hasmember.cpp

The following code example is taken from the book
C++ Templates - The Complete Guide, 2nd Edition
by David Vandevoorde, Nicolai M. Josuttis, and Douglas Gregor,
Addison-Wesley, 2017
© Copyright David Vandevoorde, Nicolai M. Josuttis, Douglas Gregor 2017


#include "hasmember.hpp"

#include <iostream>
#include <vector>
#include <utility>

DEFINE_HAS_MEMBER(size);
DEFINE_HAS_MEMBER(first);

int main()
{
  std::cout << "int::size: "
            << HasMemberT_size<int>::value << '\n';
  std::cout << "std::vector<int>::size: "
            << HasMemberT_size<std::vector<int>>::value << '\n';
  std::cout << "std::pair<int,int>::first: "
            << HasMemberT_first<std::pair<int,int>>::value << '\n';
}