Program Listing for File preprocessor-helpers.h
↰ Return to documentation for file (include\utility\preprocessor-helpers.h
)
/******************************************************************************
(c) Intel Corporation.
This software and the related documents are Intel copyrighted materials,
and your use of them is governed by the express license under which they
were provided to you ("License"). Unless the License provides otherwise,
you may not use, modify, copy, publish, distribute, disclose or transmit
this software or the related documents without Intel's prior written
permission.
This software and the related documents are provided as is, with no express
or implied warranties, other than those that are expressly stated in the
License.
******************************************************************************/
#pragma once
#include <type_traits>
#define ARRAY_SIZE(arr) std::extent<decltype(arr)>::value
template<uint32_t START, uint32_t END, template<uint32_t> class EXECUTOR>
class PREPROCESSOR_FOR
{
private:
void PREPROCESSOR_FOR_HELPER(void *, std::integral_constant<uint32_t, END>)
{
}
template<int INDEX>
void PREPROCESSOR_FOR_HELPER(void *param, std::integral_constant<uint32_t, INDEX> = std::integral_constant<uint32_t, 0>())
{
EXECUTOR<INDEX>::OnEach(param);
PREPROCESSOR_FOR_HELPER(param, std::integral_constant<uint32_t, INDEX + 1>());
}
public:
PREPROCESSOR_FOR(void *param = nullptr)
{
PREPROCESSOR_FOR_HELPER<START>(param);
}
};