Visual Computing Library
Loading...
Searching...
No Matches
inheritance.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2025 *
6 * Visual Computing Lab *
7 * ISTI - Italian National Research Council *
8 * *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the Mozilla Public License Version 2.0 as published *
13 * by the Mozilla Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * Mozilla Public License Version 2.0 *
20 * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21 ****************************************************************************/
22
23#ifndef VCL_TYPES_INHERITANCE_H
24#define VCL_TYPES_INHERITANCE_H
25
26#include <type_traits>
27
28namespace vcl {
29
30namespace detail {
31
32template<template<typename... formal> class base>
33struct IsDerivedFromImplementation
34{
35 template<typename... actual>
36 std::true_type operator()(base<actual...>*) const;
37
38 std::false_type operator()(void*) const;
39};
40
41} // namespace detail
42
63// https://stackoverflow.com/a/25846080/5851101
64// https://stackoverflow.com/questions/25845536#comment40451928_25846080
65// http://coliru.stacked-crooked.com/a/9feadc62e7594eb2
66template<typename derived, template<typename...> class base>
67using IsDerivedFromTemplateSpecialization = std::invoke_result<
68 detail::IsDerivedFromImplementation<base>,
69 typename std::remove_cv<derived>::type*>::type;
70
71} // namespace vcl
72
73#endif // VCL_TYPES_INHERITANCE_H
std::invoke_result< detail::IsDerivedFromImplementation< base >, typename std::remove_cv< derived >::type * >::type IsDerivedFromTemplateSpecialization
Utility class that allows to check if given class 'Derived' is derived from a specialization of a tem...
Definition inheritance.h:69