|
The second one: give to the function the strict necessary for its task.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
Yep, my thoughts exactly. Thank you!
Mircea
|
|
|
|
|
"great minds..."
You are welcome.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
I have a more or less strict rule i.e. to wit in particular to be specific namely things that act like pointers are passed via copy constructor not via reference since raw pointers are fundamental type objects so take up little space and a reference is a pointer anyway. I agree w/ the chap who suggested passing only what the function requires i.e. first, last iterators. Further at point of call the code is easier to understand its purpose as it passes only what the function requires also it just looks better and is easier to understand as fewer ideas/concepts are involved namely the one idea/concept "iterator" rather than the two ideas/concepts "iterator and container". Was there not a recent article in a recent CP newsletter discussing this very thing i.e. minimizing the number of ideas/concepts needed to understand any code?
|
|
|
|
|
meagreProgrammer wrote: things that act like pointers are passed via copy constructor not via reference
Except that in my case the iterator needs to be changed by the function, hence I have to pass a reference.
Mircea
|
|
|
|
|
Would it be too lengthy or tedious an explanation to explain the need to modify the iterator. I find such a need quite unusual and do not recall ever having to perform same.
|
|
|
|
|
No problem: the iterator is a pointer in a UTF-8 encoded string and the function (called next ) has to advance to the next code point (1, 2, 3 or 4 char ). If iterator is at end of string it doesn't advance.
Although a very simple function, I had a number of design decisions to make:
- How should I deal with improperly encoded UTF-8 strings? I decided to return false if the string is not properly encoded.
- Should I just leave out the boundary check and just document it? I decided against as it would have been unsafe.
And the last one I was asking about: For limit check, should I just pass the string or the end iterator.
Mircea
|
|
|
|
|
I am NOT a C++ guy, so bear with me.
I am working on a C#/WPF app that references two C++ projects.
We just converted the solution from .Net Framework to .Net Core 6.0, and now the C++ projects won't compile while in the solution. If I open the C++ projects stand-alone, they compile file.
Primarily I'm getting the compile time error
'System': a namespace with this name does not exist
I've been Googling and 99% of the answers all say this. I've tried the answers and still get the same errors.
At this point I need help. I'm guessing it's some kind of configuration issue, but I really don't know.
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
Richard MacCutchan wrote: What is the context
Not sure what you mean by "what is the context". Like I said, the project is in a solution with a C#/WPF project and the C++ project now doesn't compile.
Richard MacCutchan wrote: and are you sure this would not fit better in Managed C++/CLI Discussion Boards
I have no clue. But I could move it there.
Again, I have ZERO C++ experience, so I'm really in the dark with all this.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Kevin Marois wrote: Not sure what you mean by "what is the context" All you have given us is an error message. We have no idea whether this is unmanaged or managed code, what the actual code that causes the error looks like &c.
|
|
|
|
|
OK, so here's the lines of code that are failing:
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;
This error occurs in the using statements in every C++ file in the project.
It's a .Net 6 project, so I'm assuming it Managed code.
I'm not trying to be difficult, but I just don't know what I'm looking at so it's hard for me to know what to post here.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
OK thanks. I'll take a look
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Hi
I have the following
struct tcbholder
{
char* tcb;
char programname[8];
struct stdecs stdecsx;
list <stdecs> strptr;
list <stdecs>::iterator stfirstptr;
list <stdecs>::iterator straverse;
};
struct stdecs
{
struct vsmdesc stordesc;
char* tcb;
struct blkdesc ablkdescx;
struct blkdesc fblkdescx;
list <blkdesc> ablkptr;
list<blkdesc>::iterator blktraverse;
list<blkdesc> fblkptr;
}
struct blkdesc
{
char type;
int blkaddr;
int blklen;
};
I declare a list class
list<tcbholder> tcbcollecter;
then a iterator
list <tcbholder>::iterator tcbitrate;
I am able to initialize the main iterator
tcbitrate = tcbcollecter.begin();
However when I try
tcbitrate->straverse = tcbitrate->strptr.begin();
I get the following
_STL_VERIFY(this->_Ptr != _Mycont->_Myhead, "cannot dereference end list iterator");
its in the list member line 151
Dont Understand
Thanks
|
|
|
|
|
It means that your "tcbcollecter" list was empty when you assigned the "tcbitrate" iterator. Calling begin() on an empty list will give you the end() iterator, because there is no real element to point to. You can't dereference it because it doesn't point at anything.
|
|
|
|
|
How would I solve this problem would calling tcbitrate->push_back solve it after that there is something on the list though the members of tcbcollector have not been assigned values
|
|
|
|
|
Instead of trying to manipulate the contents of these structs from outside I would add member functions to do it.
|
|
|
|
|
Was thinking how to that don’t know if it’s practical my list represents the output of VSMLIST z/os assembler mainframe macro representing the amount allocate free and I unallocated storage for an address space
It’s listed by storage blocks ( address and length ) storage descriptors representing a storage subpool which different attributes and storage keys and the TCB task control blocks of the task that own them
|
|
|
|
|
Quote: tcbitrate = tcbcollecter.begin();
Quote: tcbitrate->straverse = tcbitrate->strptr.begin(); If tcbcollecter is empty then the complaint is correct.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
I think I finally got it a iterator is for traversing
I first have to populate the list
I’m in bed now with my iPhone I’ll try this again after work
Thanks
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|
|
Quote: Forgive me to be so bold - but I just cannot believe that in versatile forum like
this there is nobody who can at lest give me some idea how to resolve this.
It seems to be a problem that everybody wants SINGLE system problem
- that seldom works in real life.
As the title suggest - I need to connect Qt generated object / window to Linux "terminal"
(operating system ) native window.
I can highlight ( Using Qt) the text in the native window (!)
but Qt gives me no indication it did that.
PLEASE - NO PASSING THE BUCK TO QT FORUM - THEY HAVE NO IDEA HOW TO PROCEED - IT IS NOT Qt ISSUE IN THEIR ASSESSMENT -HENCE out OF THEIR narrow minded LEAGUE.
ps i WILL REMOVE THIS , AND MY SIMILAR POSTS, IF i DO NOT GET REASONABLE REPLY , JUST TO SAVE SPACE HERE.
Edited / addendum
I am still looking for somebody who is willing to help me instead of just posting text.
If it bothers you that my post is not specifically C/C++ code , please ignore it .
If it bothers you that my post is too complex , please ignore it also.
If it bothers you that my post is poorly written - read how to post / answer questions.
Is short - write something helpful and constructive.
"Terms and conditions apply to your answer."
You're doing it again, and you wonder why nobody, in any forum, is willing to even talk to you, let alone help you.
|
|
|
|
|
Member 14968771 wrote: How does terminal created window "connect" to Qt ? - that is the question. And as so often suggested, that is a question for a QT forum and has nothing to do with C/C++. Unless you can show some actual code and explain (without all the unnecessary orders) what the problem is, there is very little anyone here can do to help you. So try this template:
---------------------------
In the following code, the instruction at line x throws an out of range exception, even though the calculation appears to be correct. blah blah ...
int value = 5;
do
{
} while (values < 10);
---------------------------
That's all we need, not a load of 'instructions' about how we must answer your questions in a form that you think you deserve. Remember, we are all volunteers here and actually do this because we like to help people. What we do not care for is being given orders, especially by those who somehow think we are their employees.
|
|
|
|
|
Message Closed
modified 15-May-23 19:06pm.
|
|
|
|