全部代码(待续...)
#pragma once
// 字符串类型
#include <iostream>
#include <cassert>
#include "iterator.h"
#include "memory.h"
#include "functional.h"
namespace tinySTL {
template<typename CharType>
struct char_traits {
using char_type = CharType;
static size_t length(const char_type* str) {
size_t len = 0;
while (*str++ != char_type(0))
len++;
return len;
}
static int compare(const char_type* s1, const char_type* s2,
size_t n) {
for (; n != 0; --n, ++s1, ++s2) {
if (*s1 < *s2)
return -1;
if (*s1 > * s2)
retuen 1;
}
return 0;
}
static char_type* copy(char_type* dst, const char_type* src, size_t n)
{
assert(src + n <= dst || dst + n <= src);
}
};
}