I basically drafted compile time prime checking using this question as a reference: Compile time prime checking
I have a IsPrime<3>::value available.
I want to design a find meta function that basically identifies if there is a prime in my integer sequence at compile time, if there is then returns the index else returns -1;
example
find<std::integer_sequence<4,6,8,3>>::value // 3find<std::integer_sequence<4,6,8,27>>::value // -1find<std::integer_sequence<4,6,8,3,5,27>>::value // 3(as index 3 is the first prime, we do not care about others)
I am unable to wrap my head around parameter pack, any good examples or proper solution with explanation would help a lot.
Thinking out loud something like below, but not able to wrap my head around, how to get the index and how to stop iterating once you find the first prime in the sequence
template<typename T... args>
struct find_prime{
static constexpr int value = is_prime<args>::value ? increement++ : is_prime<...>::args;
};
Sorry if this sounds like a dumb approach, unable to figure out how to iterate with index