This is an example of how to use pow with a non numerical Monoid.
This is an example of how to use pow with a non numerical Monoid.
#include <cassert>
#include <string>
namespace power_helper {
template <>
struct Monoid<
std::string> {
static std::string
one() {
return {}; };
static std::string
prod(std::string a, std::string b) {
return a + b; }
};
}
}
assert(HPCombi::pow<0>(std::string("ab")) == "");
assert(HPCombi::pow<4>(std::string("ab")) == "abababab");
assert(HPCombi::pow<5>(std::string("abc")) == "abcabcabcabcabc");
}
int main()
Definition CF.cpp:75
Generic compile time power.
static const T prod(T a, T b)
the product of two elements of type T
Definition power.hpp:112
static const T one()
The one of type T.
Definition power.hpp:105