17 std::string
binary(
const T& a,
const bool& spacing =
true)
20 const std::uint8_t* begin =
reinterpret_cast<const std::uint8_t*
>(&a);
21 const std::uint8_t* end = begin +
sizeof(T);
22 while (begin != end) {
24 ss << std::bitset<8>(std::uint8_t(*end));
25 if (spacing && (begin != end)) ss <<
" ";
33 inline std::string
basename(
const std::string& filename) {
34 auto slash1 = filename.rfind(
'/') + 1;
35 auto slash2 = filename.rfind(
'\\') + 1;
36 if (slash2 > slash1) slash1 = slash2;
37 return filename.substr(slash1);
carl is the main namespace for the library.
std::string binary(const T &a, const bool &spacing=true)
Return the binary representation given value as bit string.
std::string basename(const std::string &filename)
Return the basename of a given filename.