Prometheus
Anyone know if there's a way to directly get the result of getline() to go to say cout instead of to a string? Trying to skip the whole saving the line into a string thing.
olli
Anonymous
Hello where can I study c/c++ and get certificate
Anonymous
I really need to study
olli
Prometheus
Here's a sample of what I wanted to do. Keep in mind I know its wrong already but it's an easy visual of what I was going for: getline(myfile, cout);
Prometheus
Instead of getline(myfile, mystring)
Prometheus
Prometheus
olli
how often do you call std::getline in your code? for each line in the file?
Prometheus
Yes, it's a loop that reads each line until eof.
olli
if you don't look at the individual lines, why not "copying" the whole file at once?
Prometheus
That was one option, I was going to try as a last resort, but I think that's only really efficient on smaller files. I'm not always aware of the file size before hand.
Prometheus
I'm testing on files that are only a few kb but I think if I tried it with files that are, for example, a few hundred mb I dont think it would be as efficient.
olli
so you are basically looking for the fastest way to copy to a stream?
Prometheus
Essentially. Fastest but if I can find one that balances speed and strain on hardware it would be best. I know it's a give and take a lot of the time, though. So I'm willing to try almost anything.
olli
Might be an interesting read then
https://stackoverflow.com/questions/10195343/copy-a-file-in-a-sane-safe-and-efficient-way
Prometheus
I'll check it out. Thanks again for all the help
Joe
@linuxer4fun @ollirz just to let you know, i managed to get it to run just by compiling it on the linux device with the gcc compiler. I think I didn`t exmplain properly what my problem was and it was way easier than expected. thanks for your help anyways!
DaviC
Hello everyone, my question is: i have a c++ code in which there is a class's declarantion function follow by one assignment to its variable
Like this:
Class::function(parameters) : variable(value){
...
}
Does anyone know what does it mean the code in "variable(value)"? Thank you😁
BinaryByter
BinaryByter
it is like putting
variable = value
inside of the function body
BinaryByter
EXCEPT that the compiler will know exactly how to optimize that
BinaryByter
that means, that it won't contstruct variable being unitialized but it will construct it with value in it
DaviC
Ok thank you very much, i had never seen it before😊
BinaryByter
sure :D
BinaryByter
btw: i'd advise you to always use that over the body-initialization
BinaryByter
that way the compiler knows how to optimize the initialization
olli
Any c++ language lawyer in here?
Is there really no compiler that issues a diagnostic? According to temp.res this should be ill-formed or shouldn't it?
template <typename ...Ts>
struct X {
X(Ts ...args) : i(1337, args...) {}
int i;
};
int main() {
X<> x;
}
BinaryByter
it shouldn't I think
BinaryByter
wait i'll find the article
BinaryByter
BinaryByter
source:
BinaryByter
http://www.cplusplus.com/articles/EhvU7k9E/
olli
BinaryByter
and its quite reliable
BinaryByter
*i'm just a noob don't mind me*
olli
they cite sources though
And of course zero is valid, but a parameter pack is only valid if am empty pack is not the only viable option.
BinaryByter
huh?
olli
In this case adding any parameter makes it ill-formed obviously.
BinaryByter
Oh I see
olli
Let me cite the std
BinaryByter
well if you don't add any arguments it shoudl be fine
olli
The program is ill-formed, no diagnostic required, if: [...] every valid specialization of a variadic template requires an empty template parameter pack
BinaryByter
I see
Box of
Have you forced it to compile in C++11?
olli
olli
Okay well apparently "no diagnostics required" means the compiler does not need to issue diagnostics or reject it
Seroney
Thanks
Anonymous
New here (lost here)
Wtf is dis planet ?
Anonymous
Anonymous
Where ?
Im human 😒
DaviC
Another question, if i have a uint32 variable that contains memory address and i want to convert it into binary number to find the opcode of my instruction, what should i do?
BinaryByter
DaviC
What did you mean?
BinaryByter
you have an array of memory, right?
BinaryByter
(you are still writing, that emulator, right?)
DaviC
Yes
BinaryByter
DaviC
Yes the both sorry
BinaryByter
alright
BinaryByter
so now you have a pointer to an opcode
BinaryByter
just access the memory at exactly that uint
BinaryByter
I hope that you use a memory model in which you map one byte in a vector to one memory adress
BinaryByter
(if your emulator works on smaller adress sizes, obviously you can use smaller or even bigger ones etc )
DaviC
In the instruction fetch i initialize my instruction uint32 with the value of the function readword(programCounter).
Then i want to access to the opcode to decode my instruction but i cant access like an array
BinaryByter
why can't you?
DaviC
Can I write instruction[26] (if my opcode begin on bit number 26) and assign it to a char?
DaviC
To compare its value in an if?
BinaryByter
BinaryByter
do you keep your instructions separate from RAM?
DaviC
No i load the program in the ram
DaviC
So i think they are inside my ram no?
BinaryByter
what?
BinaryByter
you should know, since you wrote the emulator
DaviC
No because my professor give me the skeleton, and i have to understand how it works