Though implementation problem

This is a discussion on Though implementation problem within the C++ Programming forums, part of the General Programming Boards category; So GCC compiles now?...

  1. #136
    Banned
    Join Date
    Nov 2007
    Posts
    678
    So GCC compiles now?

  2. #137
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    Yeah, it does. With no linking problems either, but VS apparently isn't completely satisfied.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #138
    Banned
    Join Date
    Nov 2007
    Posts
    678
    Quote Originally Posted by Elysia View Post
    Yeah, it does. With no linking problems either, but VS apparently isn't completely satisfied.
    Good to know that I have a good compiler (MinGW + gcc).
    Which version you are using?

  4. #139
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    I don't know. Just the latest one with Code::Blocks.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #140
    Banned
    Join Date
    Nov 2007
    Posts
    678
    Quote Originally Posted by Elysia View Post
    I don't know. Just the latest one with Code::Blocks.
    I know you will hate to do this
    But just do this on *_*command line*_*
    Code:
    gcc -v
    And post your output. Right click on command window. Click Mark. Select the region. Press Enter to copy. Paste it here!

  6. #141
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    No will do.
    EDIT: Iterators are too broken. Can't release anything yet.
    Last edited by Elysia; 05-13-2008 at 07:48 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #142
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    Alpha 1. Most things are working as they should.
    (Rename attachment to .7z)
    Current test suite:
    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"&#37;s", L"This is");
    	test.AppendFormat(L"%s", L" a test");
    #endif
    	test.Empty();
    
    	const wchar_t* t = test2;
    	t;
    }
    Might give an idea of what's possible.
    Attached Files Attached Files
    Last edited by Elysia; 05-13-2008 at 08:11 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #143
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by manav View Post
    Can you tell me why (2) is better than (1)? (2) Requires so much understanding of underground stuff! Whereas for ( ; ; ) is known to every C++ beginner!?
    Chapter 84. Prefer algorithm calls to handwritten loops

  9. #144
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    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?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #145
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,310
    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.

    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:
    Code:
    template<typename CharacterType>
    class StringIterator : public std::iterator<std::random_access_iterator_tag, CharacterType>
    {
    public:
        // ...
    };
    The operations to implement are pretty much anything a pointer can do. The SGI STL Guide has a list of them: random access iterator.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  11. #146
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    It's far easier to use Boost.Iterator's iterator_facade or iterator_adapter for implementing iterators.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  12. #147
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    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.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  13. #148
    Registered User
    Join Date
    May 2008
    Location
    Paris
    Posts
    248
    It's far easier to use Boost.Iterator's iterator_facade or iterator_adapter for implementing iterators.
    CornedBeef, can you recommend me a nice book on the Boost library?

  14. #149
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    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.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  15. #150
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  2. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 05:24 PM
  3. implementation file
    By bejiz in forum C++ Programming
    Replies: 5
    Last Post: 11-28-2005, 12:59 AM
  4. Replies: 5
    Last Post: 11-07-2005, 10:34 PM
  5. Memory Problem - I think...
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 10-24-2001, 12:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21