Implemented raii::binary to a usable level and polished the raii::string family a bit better.
This commit is contained in:
+2
-25
@@ -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<>>;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user