C++ Template Metaprogramming
Solutions to the exercises throughout the book
All Classes Namespaces Files Functions Variables Typedefs Macros Modules Pages
exercise-4-4.hpp
Go to the documentation of this file.
1// ===-- chapter-4/exercise-4-4.hpp ----------------------- -*- C++ -*- --=== //
9#ifndef EXERCISE_4_4
10#define EXERCISE_4_4
11
12#include <boost/static_assert.hpp>
13#include <boost/type_traits.hpp> // Sledge-hammer of includes.
14
15#include <boost/mpl/and.hpp>
16
34namespace exercise_4_4 {
35
41template <typename T>
43 : boost::mpl::and_<
44 boost::is_member_pointer<T>,
45 boost::mpl::not_< boost::is_member_function_pointer<T> >
46 >
47{ };
48
54template <typename T>
56 : boost::mpl::and_<
57 boost::is_pointer<T>,
58 boost::is_function<typename boost::remove_pointer<T>::type>
59 >
60{ };
61
68template <typename T>
70 : boost::mpl::and_<
71 boost::is_reference<T>,
72 boost::is_pointer<typename boost::remove_reference<T>::type>,
73 boost::is_function<
74 typename boost::remove_pointer<
75 typename boost::remove_reference<T>::type >::type >
76 >
77{ };
78
84template <typename T>
86 : boost::mpl::and_<
87 boost::is_reference<T>,
88 boost::mpl::not_<boost::is_const<
89 typename boost::remove_reference<T>::type>
90 >
91 >
92{ };
93
94} // namespace exercise_4_4
95
96#endif // EXERCISE_4_4
Encapsulate solution for Exercise 4-4.
Returns true if T is a pointer, but not a member function pointer.
Returns true if T is a pointer to a (non-member) function type.
Returns true if T is a reference to a pointer to a (non-member) function!
Returns true if T is a reference type to a constant type.