macro_overload.hpp
Go to the documentation of this file.
1 //*****************************************************************************
2 // Copyright 2017-2020 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //*****************************************************************************
16 
17 /**
18  * @brief Macro overloading feature support
19  * @file macro_overload.hpp
20  */
21 
22 #pragma once
23 
24 #define OV_ITT_MACRO_EXPAND(X) X
25 
26 #define OV_ITT_MACRO_NARG(...) OV_ITT_MACRO_EXPAND( OV_ITT_MACRO_NARG_(__VA_ARGS__, OV_ITT_MACRO_RSEQ_N()) )
27 #define OV_ITT_MACRO_NARG_(...) OV_ITT_MACRO_EXPAND( OV_ITT_MACRO_ARG_N(__VA_ARGS__) )
28 #define OV_ITT_MACRO_ARG_N(_1, _2, _3, _4, N, ...) N
29 #define OV_ITT_MACRO_RSEQ_N() 4, 3, 2, 1, 0
30 
31 #define OV_ITT_MACRO_EVAL_(NAME, N) NAME ## _ ## N
32 #define OV_ITT_MACRO_EVAL(NAME, N) OV_ITT_MACRO_EVAL_(NAME, N)
33 
34 #define OV_ITT_MACRO_OVERLOAD(NAME, ...) OV_ITT_MACRO_EXPAND( OV_ITT_MACRO_EVAL(NAME, OV_ITT_MACRO_EXPAND( OV_ITT_MACRO_NARG(__VA_ARGS__) ))(__VA_ARGS__) )