-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathis_instance_of.hpp
More file actions
32 lines (26 loc) · 864 Bytes
/
Copy pathis_instance_of.hpp
File metadata and controls
32 lines (26 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// clang-format off
/*****************************************************************//**
* \file is_instance_of.hpp
* \brief Implementation of popular Python function isinstance()
* Identify whether an object is of some specific types
* Base of a C++11 function std::is_base_of<Base, T>::value
*
* $ g++ is_instance_of.hpp -std=c++2a
*
* \author Xuhua Huang
* \date October 2021
*********************************************************************/
// clang-format on
#pragma once
#ifndef IS_INSTANCE_OF_HPP
#define IS_INSTANCE_OF_HPP
#include <type_traits>
namespace util {
namespace type {
/* Template to determine the type of parsed object. */
template <typename Base, typename T> inline bool is_instance_of(const T &) {
return std::is_base_of<Base, T>::value;
}
} // namespace type
} // namespace util
#endif // !IS_INSTANCE_OF_HPP