diff --git a/include/fc/string.hpp b/include/fc/string.hpp index 4ad1b3c..c034382 100644 --- a/include/fc/string.hpp +++ b/include/fc/string.hpp @@ -2,6 +2,25 @@ #define _FC_STRING_HPP_ #include + +/** + * There is debate about whether doing this is 'standard conforming', but + * it works everywhere and enables the purpose of this library which is to + * accelerate compiles while maintaining compatability. + */ +namespace std { + template + struct char_traits; + + template + struct allocator; + + template + struct basic_string; + + typedef basic_string, allocator > string; +} + namespace fc { /** * Including results in 4000 lines of code @@ -17,6 +36,8 @@ namespace fc { typedef const char* const_iterator; string(); + string( const std::string& s ); + string( std::string&& s ); string( const string& c ); string( string&& c ); string( const char* c ); @@ -24,6 +45,9 @@ namespace fc { string( const_iterator b, const_iterator e ); ~string(); + operator std::string&(); + operator const std::string&()const; + iterator begin(); iterator end(); diff --git a/src/string.cpp b/src/string.cpp index bb616d7..d67b246 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -44,7 +44,21 @@ namespace fc { static_assert( sizeof(my) >= sizeof(std::string), "failed to reserve enough space" ); new (this) std::string(b,e); } + string::string( const std::string& s ) { + static_assert( sizeof(my) >= sizeof(std::string), "failed to reserve enough space" ); + new (this) std::string(s); + } + string::string( std::string&& s ) { + static_assert( sizeof(my) >= sizeof(std::string), "failed to reserve enough space" ); + new (this) std::string(fc::move(s)); + } + string::operator std::string&() { + return *reinterpret_cast(this); + } + string::operator const std::string&()const { + return *reinterpret_cast(this); + } string::~string() { ::detail::destroy( this );