//******************************************************** // The following code example is taken from the book // C++17 - The Complete Guide // by Nicolai M. Josuttis (www.josuttis.com) // http://www.cppstd17.com // // The code is licensed under a // Creative Commons Attribution 4.0 International License // http://creativecommons.org/licenses/by/4.0/ //******************************************************** #include "customer1.hpp" #include // for tuple-like API // provide a tuple-like API for class Customer for structured bindings: template<> struct std::tuple_size { static constexpr int value = 3; // we have 3 attributes }; template<> struct std::tuple_element<2, Customer> { using type = long; // last attribute is a long }; template struct std::tuple_element { using type = std::string; // the other attributes are strings }; // define specific getters: template auto get(const Customer& c); template<> auto get<0>(const Customer& c) { return c.getFirst(); } template<> auto get<1>(const Customer& c) { return c.getLast(); } template<> auto get<2>(const Customer& c) { return c.getValue(); }