So GCC compiles now?
Printable View
So GCC compiles now?
Yeah, it does. With no linking problems either, but VS apparently isn't completely satisfied.
I don't know. Just the latest one with Code::Blocks.
No will do.
EDIT: Iterators are too broken. Can't release anything yet.
Alpha 1. Most things are working as they should.
(Rename attachment to .7z)
Current test suite:
Might give an idea of what's possible.Code:void Test1()
{
Strings::CStringExW test( L"test" );
Strings::CStringExW test2( L'b' );
#ifdef _MFC_VER
Strings::CStringExW test3( CString(L"test") );
Strings::CStringExW test4( CString(L'a') );
#endif
Strings::CStringExW test5(0xFFFFFFFFFFFFFFFFull);
Strings::CStringExW test6(-1LL);
Strings::CStringExW test7(-1L);
test = L"This is a test";
test = L'a';
test = 0xFFFFFFFFFFFFFFFFULL;
test = -1LL;
test = 0L;
#ifdef _MFC_VER
test = CStringW( L"test" );
test = CStringW( L'c' );
#endif
Strings::CStringExW strA(L"a"), strB(L"b");
bool b = strA < strB; // BROKEN!
b = strA > strB; // BROKEN!
//test[5];
test = L"Hi there, mommy!";
Strings::CStringExW::iterator i = test.begin();
Strings::CStringExW::iterator end = test.end();
while (++i != end);
--i;
#ifdef _MSC_VER
wcout << L"Key: " << i->Key << L", Value: " << i->Value << L" or " << *i << L"\n";
i = test.begin();
do
{
wcout << *i;
} while (++i != end);
wcout << L"\n";
std::flush(wcout);
#else
i->Key;
i->Value;
*i;
#endif
//std::vector<int>::iterator
std::swap(test, test2);
test += L"This is a test";
test += L'a';
test += 0xFFFFFFFFFFFFFFFFULL;
test += -1LL;
test += 0L;
#ifdef _MFC_VER
test += CStringW( L"test" );
test += CStringW( L'c' );
#endif
test = L"";
test = test + L"This is a test";
test = test + L'd';
test = test + 0xFFULL;
test = test + 0xFFLL;
test = test + -2L;
#ifdef _MFC_VER
test = test + CStringW( L"test" );
test = test + CStringW( L'c' );
#endif
test = 70L;
ASSERT(test == L"70");
ASSERT(test != L"1");
test = 1L;
ASSERT(test == L'1');
ASSERT(test != L'2');
test = L"a";
test.Replace(L"a", L"b");
test.Replace(L'b', L"c");
test.Replace(L"c", L'd');
test.Replace(L'd', L'e');
test.Replace(L"e", L"This is a test");
test.Replace(L"test", L"replace test");
Strings::CStringExW test8 = test.Right(4);
//int nIndex = test.Find(L"test");
//test.Delete(nIndex - 1);
//nIndex = test.Find(L'a');
//test.Delete(nIndex - 1, 2);
test += L"moo";
uint32_t nLength = test.GetLength();
wchar_t* pTest = test.GetBuffer( test.GetLength() + 1 );
wcscat_s(pTest, (test.GetLength() + 1) + 1, L"f");
test.ReleaseBuffer();
nLength = test.GetLength();
test.Truncate( test.GetLength() - 1 );
nLength = test.GetLength();
test += L" a test";
//nIndex = test.Find(L"is");
//Strings::CStringExW test9 = test.Mid(nIndex, 2);
//nIndex = test.Find(L"test");
//Strings::CStringExW test10 = test.Mid(nIndex);
#ifdef _MSC_VER
test.Format(L"%s", L"This is");
test.AppendFormat(L"%s", L" a test");
#endif
test.Empty();
const wchar_t* t = test2;
t;
}
Any ideas or hints or tutorials or references on where to get information about making your iterator compatible with STL, as to ie, use it with std::copy or std::backward_copy?
I rely on my copy of Josuttis' The C++ Standard Library for this sort of thing.Quote:
Any ideas or hints or tutorials or references on where to get information about making your iterator compatible with STL, as to ie, use it with std::copy or std::backward_copy?
std::copy takes input iterators for the source range and an output iterator for the destination range. std::copy_backword takes bidirectional iterators for the source and destination ranges. With a string class, I would expect to have random access iterators, which are a superset of all iterator types.
From what I see, you would do something like this for a string iterator template class:
The operations to implement are pretty much anything a pointer can do. The SGI STL Guide has a list of them: random access iterator.Code:template<typename CharacterType>
class StringIterator : public std::iterator<std::random_access_iterator_tag, CharacterType>
{
public:
// ...
};
It's far easier to use Boost.Iterator's iterator_facade or iterator_adapter for implementing iterators.
I've got a solid base. I'm only having trouble with const_iterators and iterators, or rather interchanging between them.
As is stands out, it really seems I have to re-implement them as separate code bases since they need to return their own appropriate class. No code reuse. It sucks.
It also complicated the fact that some arguments may need to not be const for me to properly use a non-const iterator with them.
Otherwise I have to retort to casting away const, which is to be avoided at almost all costs.
CornedBeef, can you recommend me a nice book on the Boost library?Quote:
It's far easier to use Boost.Iterator's iterator_facade or iterator_adapter for implementing iterators.
No. There isn't a single book covering all of Boost. Most of Boost is not covered by any book at all.
There's a book on the Boost Graph Library, but since this library is undergoing revision, it will be soon out of date.
The book "C++ Template Metaprogramming" deals with the MPL a lot.
There's a book called "Beyond the C++ Standard Library" which deals with some important components of Boost, like the smart pointers. Most of the stuff there has been added to the C++ standard.
Beyond that, I don't know of any books. I've gained my knowledge from reading the documentation and experimenting.
Elysia, do you have a copy of "Effective STL" by Scott Meyers?
I would HIGHLY recommend that to anyone who wants to know more about STL. I haven't found it online like C++ Coding Standards: 101 Rules, Guidelines, and Best Practices, but it's definitely worth the money to buy it.
He talks about iterators vs const_iterators as well as reverse iterators... and how to convert between the different iterator types safely.