i found a solution that does not work for the provided printme function in the question, but for similar ones:
this is what i started with:
template <typename V, typename C> bool in(const C& container, const V& element) { return std::find(container.begin(), container.end(), element) != container.end(); }
which fails to compile for eg:
in({1, 2, 3}, 1);
with
Candidate template ignored: couldn't infer template argument 'C'
based off another answer here, we could add a template specialization for std::initializer_list:
template <typename V, typename C> bool in(const C& container, const V& element) { return std::find(container.begin(), container.end(), element) != container.end(); } template <typename V> bool in(const std::initializer_list<V>& container, const V& element) { return std::find(container.begin(), container.end(), element) != container.end(); }
which looks silly.
but the following also works:
template <typename V, typename C = std::initializer_list<V>> bool in(const C& container, const V& element) { return std::find(container.begin(), container.end(), element) != container.end(); }