Indolent
Thanks for all of this help today. You're a pro!
Indolent
string s(1, 5);
Indolent
Does this means something?
Indolent
Or something like: string s(1, sample[5]) // here sample is a string eg: string sample = "abcd";
Cengizhan
Cengizhan
string s(2, 'n') -> "nn" for example.
Cengizhan
In your case, 5 is not ASCII character you cannot see what written in string probably. You should give valid character as a second parameter to string constructor if you want to use this one.
Anonymous
/get
Sasuke
I have a dynamic array of strings. Some elements contain tokens symbols like (|, &&, ||, ;) for example array ={"ls", "-la&&", "echo", "done"}
So I want to proceess differently the elements before symbol and elments after symbol.
How can I split the elements such that array look like this array ={"ls", "-la", "&&", "echo", "done"}
Martin
I have a dynamic array of strings. Some elements contain tokens symbols like (|, &&, ||, ;) for example array ={"ls", "-la&&", "echo", "done"}
So I want to proceess differently the elements before symbol and elments after symbol.
How can I split the elements such that array look like this array ={"ls", "-la", "&&", "echo", "done"}
You write a parser.
Martin
The simple but limited way is to hand write state machines to only split settings at the appropriate location.
Martin
The more complex also powerful approach is to use something like Flex/Bison to generate a full-blown parser. And use the parser to parse.
Sasuke
Sasuke
Martin
Plain 'split' won't do it.
Martin
What are these things
flex and bison are parser generators. Tell them what input is like. They generate a parser for the input
Sasuke
Martin
More or less, yes
Sasuke
More or less, yes
I also have single array of chars too if operation on that is easier
Martin
Sasuke
Space around symbol
Martin
Yes. You need to write a loop manually to do it. Create another array of chars thats long enough. Loop through the input array of characters. If you find a special symbol after a normal character. Add a space to the new array before copying the character
Sasuke
Sasuke
So I may end up adding extra space
Martin
So I may end up adding extra space
This is where things get really tricky. The simple solution I described above have a lot of edge cases. It might insert extra spaces when it shouldn't (let's say, in a quoted string)
Martin
The only 100% correct way is to write a parser according to sh/bash/zsh 's grammar rules. It's gonna be very hard
Martin
But the simple way will get you 90% there.
Sasuke
Sasuke
Am already stressed
Sasuke
Dima
Okay
Aurora
who use cocos2d-x
Pavel
I_Interface
lol
Taha
Hello guys what is the perfect library in c++ to work with encryption and thank u
Hermann
Taha
数学の恋人
how does arbitrary precision in float work in C++? I have seen few libraries that provide arbitrary precision, like GMP, fprecision (Modified GMP), LEDA's bigfloat, etc. But I don't seem to find how they are actually doing it. I know I can just read the source code, but it's too long and I'm in kinda hurry and I want to implement it myself
Artöm
They store array of ints and use formulas to calculate stuff
Artöm
It definitely is
数学の恋人
it seems overwhelming once but isn't much of a deal
数学の恋人
thanks for reminding, very much appreciated.
Taha
Can i see the code source
Wisenky
https://github.com/tensorflow/tensorflow how do they compile this projects written in many languages
Anonymous
Artöm
correctmaninwrongplace
Hello, i have a doubt, if i call std::vector<int> second (4);
it will create a vector of 4 elements or just will create an empty vector with space for 4 elements?
Alex
Anonymous
Anonymous
But yeah it creates the vector of 4 elements
Anonymous
In Java or C# same data structures set the capacity
correctmaninwrongplace
cppreference.com :)
it says
fill constructor
Constructs a container with n elements. Each element is a copy of val (if provided).
if provided, but if i dont provide it?
Alex
Anonymous
Anonymous
/get dsa
Anonymous
/get
ᡕᠵ᠊ᡃ࡚ࠢ࠘ ⸝່ࠡࠣ᠊߯᠆ࠣ࠘ᡁࠣ࠘᠊᠊ࠢ࠘𐡏⁻
I need the beat explain to know what is DLL
Anonymous
Anonymous
Patrick
Must I use unique_ptr or can I just delete the copy operator and constructor of my class?
Anonymous
Anonymous
There's no "copy operator"
Patrick
X& operator=(const X&)
Patrick
assignment
Anonymous
It's copy assignment operator
Anonymous
Anonymous
If you need to delete any function, you can add = delete; after its signature
Patrick
I'm thinking, instead of using this all the time:
unique_ptr<X>
in my class X I could just do:
X& operator=(const X&) = delete;
X(const X&) = delete;
Patrick
Is it functionally similar to unique_ptr in that it will prevent copies, and must be moved?
Anonymous
No one uses std::unique_ptr to prevent copies of objects
Anonymous