Skip to content
Snippets Groups Projects
Commit 368d3284 authored by Alexander Peyser's avatar Alexander Peyser Committed by Sam Yates
Browse files

Add initializer_list version for is_in in modccutil.hpp (#122)

Fix `is_in` compilation error with initializer lists and clang 3.7.1.

Addresses part of issue #121: `template <typename T, int N> bool is_in(T thing, const T (&list)[N])` fails to match against an initializer list second argument with clang-3.7.1 in `modcc/cprinter.cpp`.

* Add overload `template <typename T> bool is_in(T thing, const std::initializer_list<T> list) ` for `is_in` in `modccutil.hpp`. Fixes clang issue and verified to work with a version of gcc as well.
parent d73f2240
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
#include <memory>
#include <sstream>
#include <vector>
#include <initializer_list>
// is thing in list?
template <typename T, int N>
......@@ -16,6 +17,16 @@ bool is_in(T thing, const T (&list)[N]) {
return false;
}
template <typename T>
bool is_in(T thing, const std::initializer_list<T> list) {
for(auto const& item : list) {
if(thing==item) {
return true;
}
}
return false;
}
inline std::string pprintf(const char *s) {
std::string errstring;
while(*s) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment