SpaIot Library
type_name.h
1/*
2 * SpaIot Library (c) by epsilonrt - epsilonrt@gmail.com
3 * This file is part of SpaIot library <https://github.com/epsilonrt/spaiot-lib>
4 *
5 * SpaIot library is licensed under a
6 * Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
7 *
8 * You should have received a copy of the license along with this
9 * work. If not, see <http://creativecommons.org/licenses/by-nc-sa/4.0/>.
10 *
11 * SpaIot library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY;
13 */
14#pragma once
15
16#include <Arduino.h>
17
22template <class T>
23String type_name (const T&) {
24 String s = __PRETTY_FUNCTION__;
25 int start = s.indexOf ("[with T = ") + 10;
26 int stop = s.lastIndexOf (']');
27 return s.substring (start, stop);
28}