Move _KiB and _MiB user-defined literals to utility.hpp.

Where I put all the stuff I don't know where to put.
This commit is contained in:
Jared Boone 2015-08-20 17:15:51 -07:00
parent 1c3e45917c
commit 4b7780f5c6
2 changed files with 10 additions and 8 deletions

View File

@ -28,6 +28,8 @@
#include "lpc43xx_cpp.hpp" #include "lpc43xx_cpp.hpp"
using namespace lpc43xx; using namespace lpc43xx;
#include "utility.hpp"
namespace portapack { namespace portapack {
namespace memory { namespace memory {
@ -58,14 +60,6 @@ private:
const size_t size_; const size_t size_;
}; };
constexpr size_t operator "" _KiB(unsigned long long v) {
return v * 1024;
}
constexpr size_t operator "" _MiB(unsigned long long v) {
return v * 1024 * 1024;
}
namespace map { namespace map {
constexpr region_t local_sram_0 { 0x10000000, 96_KiB }; constexpr region_t local_sram_0 { 0x10000000, 96_KiB };

View File

@ -32,6 +32,14 @@
#define LOCATE_IN_RAM __attribute__((section(".ramtext"))) #define LOCATE_IN_RAM __attribute__((section(".ramtext")))
constexpr size_t operator "" _KiB(unsigned long long v) {
return v * 1024;
}
constexpr size_t operator "" _MiB(unsigned long long v) {
return v * 1024 * 1024;
}
template<typename E> template<typename E>
constexpr typename std::underlying_type<E>::type toUType(E enumerator) noexcept { constexpr typename std::underlying_type<E>::type toUType(E enumerator) noexcept {
/* Thanks, Scott Meyers! */ /* Thanks, Scott Meyers! */