string file work

This commit is contained in:
rexy712
2019-12-21 06:44:23 -08:00
parent 913a9f6430
commit 0051760884
3 changed files with 65 additions and 68 deletions
+48 -52
View File
@@ -26,45 +26,6 @@
namespace raii{
class string_expr{};
class string_base;
namespace detail{
std::true_type is_string_helper(string_expr);
std::false_type is_string_helper(...);
template<class T>
struct is_string{
static constexpr bool value = std::is_same<std::true_type,decltype(is_string_helper(std::declval<T>()))>::value;
};
std::true_type is_string_base(string_base*);
std::false_type is_string_base(...);
template<class T>
struct is_concrete_string{
static constexpr bool value = std::is_same<std::true_type,decltype(is_string_base(std::declval<typename std::decay<T>::type*>()))>::value;
};
template<class... Args>
std::true_type is_tuple_helper(std::tuple<Args...>);
std::false_type is_tuple_helper(...);
template<class T>
struct is_tuple{
static constexpr bool value = std::is_same<std::true_type,decltype(is_tuple_helper(std::declval<T>()))>::value;
};
//check for member function 'length'
template<class T>
struct has_len{
template<class U, class V>
struct check;
template<class U>
static std::true_type test(check<U,decltype(&U::length)>*);
template<class U>
static std::false_type test(...);
static constexpr bool value = std::is_same<std::true_type,decltype(test<T>(0))>::value;
};
}
//Base of all RAII strings. Its use is allowing passing of raii strings to functions without knowing the exact type
class string_base : public string_expr
@@ -166,19 +127,6 @@ namespace raii{
constexpr const Right& right(void)const;
};
template<class Targ>
struct appender
{
private:
Targ& m_targ;
size_t m_pos = 0;
public:
appender(Targ& t);
template<class L, class R>
void operator()(const string_cat_expr<L,R>& str);
void operator()(const string_base& str);
};
class static_string : public string_base
{
public:
@@ -196,6 +144,54 @@ namespace raii{
static_string& operator=(static_string&&) = delete;
};
namespace detail{
std::true_type is_string_helper(string_expr);
std::false_type is_string_helper(...);
template<class T>
struct is_string{
static constexpr bool value = std::is_same<std::true_type,decltype(is_string_helper(std::declval<T>()))>::value;
};
std::true_type is_string_base(string_base*);
std::false_type is_string_base(...);
template<class T>
struct is_concrete_string{
static constexpr bool value = std::is_same<std::true_type,decltype(is_string_base(std::declval<typename std::decay<T>::type*>()))>::value;
};
template<class... Args>
std::true_type is_tuple_helper(std::tuple<Args...>);
std::false_type is_tuple_helper(...);
template<class T>
struct is_tuple{
static constexpr bool value = std::is_same<std::true_type,decltype(is_tuple_helper(std::declval<T>()))>::value;
};
//check for member function 'length'
template<class T>
struct has_len{
template<class U, class V>
struct check;
template<class U>
static std::true_type test(check<U,decltype(&U::length)>*);
template<class U>
static std::false_type test(...);
static constexpr bool value = std::is_same<std::true_type,decltype(test<T>(0))>::value;
};
template<class Targ>
struct appender
{
private:
Targ& m_targ;
size_t m_pos = 0;
public:
appender(Targ& t);
template<class L, class R>
void operator()(const string_cat_expr<L,R>& str);
void operator()(const string_base& str);
};
}
}
#include "raii/string_base.tpp"