1/*
2 * check_no_pointers.hpp
3 *
4 * Created on: Jul 7, 2015
5 * Author: i-bird
6 */
7
8#ifndef CHECK_NO_POINTERS_HPP_
9#define CHECK_NO_POINTERS_HPP_
10
11#include "common.hpp"
12
13/*! \brief return type of check_no_pointers
14 *
15 *
16 */
17enum PNP
18{
19 POINTERS,
20 NO_POINTERS,
21 UNKNOWN
22};
23
24//! Check if the type T has pointers inside
25template<typename T, bool has_pointer=has_noPointers<T>::type::value >
26struct check_no_pointers_impl
27{
28 //! Return true if the structure T has a pointer
29 static size_t value() {return T::noPointers();}
30};
31
32//! Check if the type T has pointers inside
33template<typename T>
34struct check_no_pointers_impl<T,false>
35{
36 //! Return PNP::UNKNOWN if the structure T does not specify if it has a pointer
37 static size_t value() {return PNP::UNKNOWN;};
38};
39
40/*! \brief This class check if the type T has pointers inside
41 *
42 * It basically check if exist a function bool T::noPointers(), if not return UNKOWN
43 * if exist it return the noPointers return status
44 *
45 * \tparam T type to check
46 *
47 * ### Example
48 *
49 * \snippet util_test.hpp Check no pointers in structure
50 *
51 */
52template<typename T>
53struct check_no_pointers
54{
55 static size_t value() {return check_no_pointers_impl<T>::value();}
56};
57
58
59
60
61#endif /* CHECK_NO_POINTERS_HPP_ */
62