Minimal Reproducible Example
#include <unordered_map>
#include <string>
template<class T, bool did_work>
class Test {
Test(T input) : field(input), success(did_work) {}
T field;
bool success;
};
template<typename A>
void func(std::unordered_map<std::string, Test<A, bool>> input1, A input2) {}
int main() {}
Output:
$ g++ -std=c++17 -ggdb -g3 -Wall test.cpp && ./a.out
test.cpp:12:51: error: type/value mismatch at argument 2 in template parameter list for ‘template<class T, bool did_work> class Test’
12 | void func(std::unordered_map<std::string, Test<A, bool>> input1, A input2) {}
| ^~~~
test.cpp:12:51: note: expected a constant of type ‘bool’, got ‘bool’
test.cpp:12:55: error: template argument 2 is invalid
12 | void func(std::unordered_map<std::string, Test<A, bool>> input1, A input2) {}
| ^~
test.cpp:12:55: error: template argument 5 is invalid
I need to be able to pass in unordered_map<std::string, Test<A, true>> as well as unordered_map<std::string, Test<A, false>>. Is there a way to do this in the function definition without changing the class Test definition?