nac3/nac3core/irrt/test/print.hpp

42 lines
627 B
C++
Raw Normal View History

2024-07-12 22:29:04 +08:00
#pragma once
#include <cstdlib>
#include <cstdio>
template <class T>
2024-07-13 23:58:29 +08:00
void print_value(T value);
2024-07-12 22:29:04 +08:00
template <>
2024-07-13 23:58:29 +08:00
void print_value(char value) {
printf("'%c' (ord=%d)", value, value);
}
template <>
void print_value(int8_t value) {
2024-07-12 22:29:04 +08:00
printf("%d", value);
}
template <>
2024-07-13 23:58:29 +08:00
void print_value(int32_t value) {
2024-07-12 22:29:04 +08:00
printf("%d", value);
}
template <>
2024-07-13 23:58:29 +08:00
void print_value(uint8_t value) {
2024-07-12 22:29:04 +08:00
printf("%u", value);
}
template <>
2024-07-13 23:58:29 +08:00
void print_value(uint32_t value) {
2024-07-12 22:29:04 +08:00
printf("%u", value);
}
template <>
2024-07-13 23:58:29 +08:00
void print_value(double value) {
2024-07-12 22:29:04 +08:00
printf("%f", value);
}
2024-07-13 23:58:29 +08:00
template <>
void print_value(char* value) {
printf("%s", value);
}