Skip to content

Commit 76958c6

Browse files
committed
move IsSpecializatinoOf to PMacc
1 parent f6e2768 commit 76958c6

File tree

3 files changed

+64
-21
lines changed

3 files changed

+64
-21
lines changed

include/picongpu/plugins/binning/FieldInfo.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#pragma once
22

3-
#include "picongpu/plugins/binning/utility.hpp"
4-
53
#include <pmacc/Environment.hpp>
64
#include <pmacc/dataManagement/DataConnector.hpp>
5+
#include <pmacc/traits/IsSpecializationOf.hpp>
76

87
#include <string>
98
#include <string_view>
@@ -33,9 +32,9 @@ namespace picongpu::plugins::binning
3332
}
3433
};
3534

36-
auto transformFieldInfo(auto&& arg) -> decltype(auto)
35+
decltype(auto) transformFieldInfo(auto&& arg)
3736
{
38-
if constexpr(IsSpecializationOf<std::decay_t<decltype(arg)>, FieldInfo>)
37+
if constexpr(pmacc::concepts::SpecializationOf<std::decay_t<decltype(arg)>, FieldInfo>)
3938
{
4039
pmacc::DataConnector& dc = pmacc::Environment<>::get().DataConnector();
4140
return dc

include/picongpu/plugins/binning/utility.hpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,5 @@ namespace picongpu
107107
return std::unique_ptr<std::remove_cvref_t<decltype(*ptr)>>(ptr);
108108
}
109109

110-
template<typename, template<typename...> typename>
111-
struct is_specialization_of : std::false_type
112-
{
113-
};
114-
115-
template<template<typename...> typename Template, typename... Args>
116-
struct is_specialization_of<Template<Args...>, Template> : std::true_type
117-
{
118-
};
119-
120-
// TODO reverse this order
121-
template<typename T, template<typename...> typename Template>
122-
inline constexpr bool is_specialization_of_v = is_specialization_of<T, Template>::value;
123-
124-
template<typename T, template<typename...> typename Template>
125-
concept IsSpecializationOf = is_specialization_of_v<T, Template>;
126-
127110
} // namespace plugins::binning
128111
} // namespace picongpu
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/* Copyright 2025 Tapish Narwal
2+
*
3+
* This file is part of PMacc.
4+
*
5+
* PMacc is free software: you can redistribute it and/or modify
6+
* it under the terms of either the GNU General Public License or
7+
* the GNU Lesser General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* PMacc is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License and the GNU Lesser General Public License
15+
* for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* and the GNU Lesser General Public License along with PMacc.
19+
* If not, see <http://www.gnu.org/licenses/>.
20+
*/
21+
22+
#pragma once
23+
24+
#include <type_traits>
25+
26+
namespace pmacc
27+
{
28+
namespace traits
29+
{
30+
31+
/**
32+
* Type trait to check if a type is a specialization of a template
33+
* Similar to P2078 - https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2098r0.pdf
34+
* Note that this cant be used with template types which have NTTPs
35+
* To fix this limitation we need PR1985 Universal Template Parameters
36+
* https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1985r3.pdf
37+
*/
38+
39+
template<typename, template<typename...> typename>
40+
struct IsSpecializationOf : std::false_type
41+
{
42+
};
43+
44+
template<template<typename...> typename Template, typename... Args>
45+
struct IsSpecializationOf<Template<Args...>, Template> : std::true_type
46+
{
47+
};
48+
49+
} // namespace traits
50+
51+
template<typename T, template<typename...> typename Template>
52+
inline constexpr bool isSpecializationOf_v = traits::IsSpecializationOf<T, Template>::value;
53+
54+
namespace concepts
55+
{
56+
template<typename T, template<typename...> typename Template>
57+
concept SpecializationOf = isSpecializationOf_v<T, Template>;
58+
59+
} // namespace concepts
60+
61+
} // namespace pmacc

0 commit comments

Comments
 (0)