Implemented raii::binary to a usable level and polished the raii::string family a bit better.

This commit is contained in:
rexy712
2019-09-18 14:29:57 -07:00
parent 57ed5d979f
commit 60b380f14e
13 changed files with 334 additions and 220 deletions
+2 -25
View File
@@ -20,35 +20,12 @@
#define RAII_STRING_HPP
#include "raii/string_base.hpp"
#include <new> //operator new/delete
#include <cstring> //memcpy
#include "raii/default_allocator.hpp"
namespace raii{
namespace detail{
class default_allocator
{
public:
static void free(void* data){
::operator delete(data);
}
static void* allocate(size_t size){
return ::operator new(size);
}
static void* copy(const void* c, size_t size){
char* tmp = reinterpret_cast<char*>(allocate(size));
memcpy(tmp, c, size-1);
tmp[size-1] = 0;
return tmp;
}
};
}
//new allocated string
using string = string_intermediary<detail::default_allocator>;
using string = string_intermediary<detail::default_allocator<>>;
}