constexpr int ipow(int x, int n) {
return (n > 0) ? x * ipow(x, n - 1): 1;
}
template <char c>
constexpr int b3_helper() {
static_assert(c < '3', "not a ternary digit");
return c - '0';
}
template <char c, char... chars>
constexpr int b3_helper() {
static_assert(c < '3', "not a ternary digit");
return ipow(3, sizeof...(chars)) * (c - '0') + b3_helper<chars...>();
}
template <char... chars>
constexpr int operator"" _b3() {
return b3_helper<chars...>();
}
int main(){
int i = 201_b3;
return 0;
}
编译器说
第 12 行对“b3_helper”的调用不明确”;
我该如何解决?我在学习 C++ 编程语言 4th 时发现了这个问题。在第 560 页