C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 05-18-2008, 08:24 AM   #241
Mysterious C++ User
 
Elysia's Avatar
 
Join Date: Oct 2007
Posts: 14,785
Quote:
Originally Posted by phantomotap View Post
It is nonsense.
1): Nothing is stopping them from supporting C and C++ correctly.
2): As I've said, they use 'pragma' everywhere to turn off and on other warnings and errors.
2) It still won't compile without extensions added, so it's not nonsense.
Besides, the headers use a lot of things like re-define of defines (without #undef first). Regardless if it ignores this or not, it's not allowed. If extensions are disabled, you get compile errors.

Code:
#define __$adt_prop(adt,prop)
2>d:\program\microsoft sdks\windows\v6.0a\include\specstrings.h(171) : error C2008: '$' : unexpected in macro definition
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.

Last edited by Elysia; 05-18-2008 at 08:31 AM.
Elysia is offline   Reply With Quote
Old 05-18-2008, 08:32 AM   #242
Registered User
 
Join Date: Jan 2008
Posts: 642
Quote:
2) It still won't compile without extensions added, so it's not nonsense.
Besides, the headers use a lot of things like re-define of defines (without #undef first). Regardless if it ignores this or not, it's not allowed. If extensions are disabled, you get compile errors.
This is getting very tiresome. That the headers use extensions is a nonsense reason to not error on code that is an error. As I've said, twice, they use 'pragma' everywhere to turn off and on other warnings and errors. They already use 'pragma' to protect the headers from raising warnings and errors that the compiler does care about.

Soma
phantomotap is offline   Reply With Quote
Old 05-18-2008, 08:49 AM   #243
Mysterious C++ User
 
Elysia's Avatar
 
Join Date: Oct 2007
Posts: 14,785
And yet the headers won't compile with language extensions OFF. And that is all we care about.
If it can't compile them without extensions, then the headers are flawed, because they aren't standard compliant are they?
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Old 05-18-2008, 09:03 AM   #244
Registered User
 
Join Date: Jan 2008
Posts: 642
Quote:
And yet the headers won't compile with language extensions OFF.
Which is a nonsense reason for the compiler to not raise an error on code that is an error.

Quote:
And that is all we care about.
I don't care about it at all. I don't use the Microsoft headers even when I use the Microsoft compiler. I do care about my source being valid and sound. I expect the compiler to raise an error regarding invalid code.

Quote:
If it can't compile them without extensions, then the headers are flawed, because they aren't standard compliant are they?
As I've said, thrice, they use 'pragma' everywhere to turn off and on other warnings and errors. The headers do depend on some extensions, but so what? That doesn't change the fact that the compiler is allowing nonconforming code a pass.

Soma
phantomotap is offline   Reply With Quote
Old 05-18-2008, 11:43 AM   #245
Mysterious C++ User
 
Elysia's Avatar
 
Join Date: Oct 2007
Posts: 14,785
Well, we obviously have different views or do not understand each other, so I'll leave it at that. I have no further wish to argue.
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Old 05-20-2008, 09:24 AM   #246
Mysterious C++ User
 
Elysia's Avatar
 
Join Date: Oct 2007
Posts: 14,785
Another question I'm thinking on:
Say that CIterator takes a constructor with int:
CIterator(int)
This is not enough information to properly construct the iterator, however. Therefore, it would want to ask the owner class to which it belongs or is constructed for for the rest of the information.
Typically, it would do this via the proxy:
m_pProxy->QueryRange(m_pRangeStart, m_pRangeEnd);
However, since it's newly constructed, it doesn't have the owner class address or a valid proxy pointer, so it can't really do much.

Now the question becomes - is it possible, then, to somehow pass along the address for the class for either the correct proxy instance or the owner class?
The reason is that the int constructor is supposed to be an implicit constructor to should allow this:

CStringEx test = "test";
test.Find("test", 0);

Find's prototype would be:

Find(const CStringEx& strFind, CIterator vStart);

This would invoke the int constructor for CIterator for int. The constructor would then set itself to test.begin() + n.
But I can't seem to find a viable solution for the iterator to get the address the owner class so as to be able to make this possible.

Is it perhaps just too much of a hassle to make it possible?
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Old 05-20-2008, 09:44 AM   #247
The larch
 
Join Date: May 2006
Posts: 3,222
What about this?
Code:
Find(const CStringEx& strFind, unsigned nPos)
{
     CIterator vIter(nPos, this);
     ...
}
With an overload for passing a CIterator...
__________________
I might be wrong.

Quote:
Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
Quoted more than 1000 times (I hope).
anon is offline   Reply With Quote
Old 05-20-2008, 11:47 AM   #248
Mysterious C++ User
 
Elysia's Avatar
 
Join Date: Oct 2007
Posts: 14,785
That's one solution I didn't think of... it will probably mean two overloaded functions, but hey, who cares.
Suppose I'll do that unless I can find a better solution.
Thanks.
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Old 05-20-2008, 12:08 PM   #249
The larch
 
Join Date: May 2006
Posts: 3,222
Code:
Find(const CStringEx& strFind, unsigned nPos)
{
     CIterator vIter(nPos, this);
     return Find(strFind, vIter);
}

Find(const CStringEx& strFind, CIterator vStart)
{
    ...
}
What happens if the passed iterator does not refer to this CStringEx?
__________________
I might be wrong.

Quote:
Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
Quoted more than 1000 times (I hope).
anon is offline   Reply With Quote
Old 05-20-2008, 12:10 PM   #250
Mysterious C++ User
 
Elysia's Avatar
 
Join Date: Oct 2007
Posts: 14,785
The functions will always accept T::iterator.
Such as my current free Find function:
Code:
template<typename StrType> typename StrType::const_iterator Find(const StrType& strFind,
	const typename StrType::const_iterator& vStart, 
	const typename StrType::const_iterator& vEnd);
By using proper typedefs in the class, it will make sure that the iterator is compatible with the class.
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Old 05-20-2008, 03:37 PM   #251
Cat without Hat
 
CornedBee's Avatar
 
Join Date: Apr 2003
Posts: 8,492
But what if that iterator points into a different instance of StrType? That's what anon was asking.

(Of course, in the STL, that's simply undefined, but you're not a fan of undefined behaviour.)
__________________
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
CornedBee is offline   Reply With Quote
Old 05-20-2008, 03:39 PM   #252
Mysterious C++ User
 
Elysia's Avatar
 
Join Date: Oct 2007
Posts: 14,785
That would throw an exception.
Code:
if ( !vStart.valid_instance(strSrc) || !vEnd.valid_instance(strSrc) )
	throw errInvalidIterator;
No more undefined.
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.

Last edited by Elysia; 05-20-2008 at 04:04 PM.
Elysia is offline   Reply With Quote
Old 05-20-2008, 05:02 PM   #253
Registered User
 
Join Date: Jan 2008
Posts: 642
Why not design the container/iterator model up such that the validate method is part of the iterator class? With such a design the validate method could examine the state of iterator for correctness and optionally update the owning container of the iterator if it was spawned from such constructs as this implicit conversion constructor.

Soma
phantomotap is offline   Reply With Quote
Old 05-21-2008, 01:20 AM   #254
Mysterious C++ User
 
Elysia's Avatar
 
Join Date: Oct 2007
Posts: 14,785
The valid_instance function is part of the iterator class.
It takes a const reference to the base object to validate.
It uses its proxy to query which owning object it's bound against and compares the address of the passed argument. If they don't match, it returns false. In other words, if the object passed through reference is an instance that is not the instance of the owning object, it returns false.
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Old 05-25-2008, 05:27 AM   #255
Mysterious C++ User
 
Elysia's Avatar
 
Join Date: Oct 2007
Posts: 14,785
New wonder:
I have the following free operator:
Code:
CTmplStringBaseTemplate CTmplStringBaseTmpl& operator +=
	(CTmplStringBaseTmpl& rlhs, const CTmplStringBaseTmpl& rrhs);
But if I try to call it through the code:
Code:
Strings::CStringExW test( L"test" );
test += L"This is a test";
I simply get an error:
Code:
error C2784: 'Strings::CTmplStringBase<T,Strings::StrTraits<T>> &Strings::operator +=
	(Strings::CTmplStringBase<T,Strings::StrTraits<T>> &,
	const Strings::CTmplStringBase<T,Strings::StrTraits<T>> &)' :
could not deduce template argument for
'const Strings::CTmplStringBase<T,Strings::StrTraits<T>> &'
from
'const wchar_t [15]' 
I even tried changing the function to:
Code:
template<typename T> CTmplStringBase<T, StrTraits<T>>& operator +=
	(CTmplStringBase<T, StrTraits<T>>& rlhs,
	const CTmplStringBase<T, StrTraits<T>>& rrhs/*const T* strData*/);
Yet still refuses to work. But technically, it should, because the class has constructors (not-explicit) for the types:
Code:
CTmplStringBase();
CTmplStringBase(const CTmplStringBase& rSrc);
#ifdef _MFC_VER
CTmplStringBase(const CStringT< T, StrTraitMFC_DLL<T> >& strSrc);
#endif
CTmplStringBase(const T* strData);
CTmplStringBase(const T cData);
CTmplStringBase(uint64_t nData);
CTmplStringBase(int64_t nData);
CTmplStringBase(long nData);
So shouldn't it be able to create a temp object for the wchar_t* (using CTmplStringBase<wchar_t>) and then pass via a const reference?
I must be doing something wrong here...
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.

Last edited by Elysia; 05-25-2008 at 07:24 AM.
Elysia is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
WS_POPUP, continuation of old problem blurrymadness Windows Programming 1 04-20-2007 06:54 PM
Laptop Problem Boomba Tech Board 1 03-07-2006 06:24 PM
implementation file bejiz C++ Programming 5 11-28-2005 01:59 AM
Sorting problem.. well actually more of a string problem fatdunky C Programming 5 11-07-2005 11:34 PM
Memory Problem - I think... Unregistered C Programming 4 10-24-2001 12:14 PM


All times are GMT -6. The time now is 11:45 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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