Ashish Bhushan
Help me
Have you typed the correct adrress ??
Ashish Bhushan
I mean is your file in G disk and in c programming folder?
Ashish Bhushan
Also you can use the code runner extension in vs code foe compiling and execution of your programs
Alberto
Hi everyone, need some help :s I was codding with some threads and using some semaphores but all the threads block when wating :S
Alberto
semaphores init
Alberto
they all are blocked in sem_wait(&(cola->num_huecos));
Alberto
tam_cola = 8
Alberto
Hi?
Hassu
My all msg got cleared?? WoW
klimi
My all msg got cleared?? WoW
yes, for offtopic use please offtopic group, thank you
Zildj1an
In case any of you wants a challenge (& help me) this beautiful morning: https://stackoverflow.com/questions/61206763/problems-compiling-a-kernel-i-have-modified
Ajay
What's comp for in `template ForwardIterator max_element (ForwardIterator first, ForwardIterator last, Compare comp);`?
Mar!o
Parameter name
Ajay
what's the difference with normal max_element function?
Mar!o
Pls aend the whole code...
Abdelnaem
Hi everyone
klimi
Abdelnaem
Are you here learn C++
Pavel
What's comp for in `template ForwardIterator max_element (ForwardIterator first, ForwardIterator last, Compare comp);`?
comp is a comparator functor. Basically a "function" that compares two elements. The difference with using a function overload without comparator that it will use default operator < (less than). There can be cases when: - there's no such operator - there is such an operator, but you want to find "max element" by some other crieria (for example your "less than" operator compares ID field of your structure, but you want to find a structure with maximum Age field).
Pavel
so a max_element() with a comparator a<b and without a comparator are equivalent?
They are equivalent only if your comparator have the same logic as operator<
Ajay
They are equivalent only if your comparator have the same logic as operator<
ok so that way i can customise it to return the min element of an array of ints by changing the comparator to a>b?
Pavel
You can try it
Ajay
They are equivalent only if your comparator have the same logic as operator<
also, what does the meaning < hold there, if they are equivalent?
Ajay
also, what does the meaning < hold there, if they are equivalent?
i mean max_element returns the max element with < as the comparator but how do I interpret < intuitively?
Pavel
also, what does the meaning < hold there, if they are equivalent?
Well, comparison operators can be used for many things (e.g. using containers such a std::map)
Ajay
Well, comparison operators can be used for many things (e.g. using containers such a std::map)
I guess, for a map it decides how the elements are stored in red-black tree?
Pavel
I guess, for a map it decides how the elements are stored in red-black tree?
Yes, you need to be able to correctly tell whether one element is less than another to be able to build a correct binary tree (not only red-black)
Ajay
Yes, you need to be able to correctly tell whether one element is less than another to be able to build a correct binary tree (not only red-black)
What's the intuition behind using < as the comparator in case of the max_element function? or is that i should just remember that < helps in finding the max element and hence > will help in finding the min element
Pavel
What's the intuition behind using < as the comparator in case of the max_element function? or is that i should just remember that < helps in finding the max element and hence > will help in finding the min element
Nope, I might said it in an incorrect way. You define your operator< as well with other operators to be able to compare them. When you do you don't think much about the algorithms that you will use on them, just that they should be compared in some predictable manner that makes sense for this type. Then, when you use an algorithm like max_element, you either go along with your default operator< if it's what you need, or you use that version with comp that we've started from. In the second case you use that comparator to achieve the behavior that you need from the algorithm.
Pavel
About using greater than in the comparator, different algorithms can require different behavior from the comparators (e.g. search requires equality)
Pavel
asking about the second case, i wanted to ask that how does comparator uses < help in finding the max_element.
You can note in the Possible Implementation section how they can use it. https://en.cppreference.com/w/cpp/algorithm/max_element
Pavel
Why operator<, I guess it's how it used to be historically that algorithms use this operator when it's appropriate. So user can implement the minimal amount of operators. If max_element would use operator> for example and operator< would be used for other algorithms, they would force the user to implement them all.
Pavel
BTW, these implementation depend upon which factors?
Developers of specific compilers may use different implementations (for example if they find a more efficient way to implement that algorithm)
Chaki
Hi guys, I have some problems with using other libraries in C++ Visual Studio. My question is after adding include folder in C/C++ -> General -> Adding include directories, should I link lib files in Linker section?
Ajay
https://stackoverflow.com/questions/10476665/avoiding-copy-of-objects-with-the-return-statement
Ajay
https://stackoverflow.com/questions/10476665/avoiding-copy-of-objects-with-the-return-statement
#include <iostream> struct A { int a; int b; int c; int d; }; A create(int i) { A a = {i, i+1, i+2, i+3 }; std::cout << &a << "\n"; return a; } int main(int argc, char*[]) { A a = create(argc); std::cout << &a << "\n"; }
Ajay
#include <iostream> struct A { int a; int b; int c; int d; }; A create(int i) { A a = {i, i+1, i+2, i+3 }; std::cout << &a << "\n"; return a; } int main(int argc, char*[]) { A a = create(argc); std::cout << &a << "\n"; }
In this statement, if the structure is "copied(and not moved)" to the "return slot", then what's the fun of using return slot if instead the "return slot" isn't allocated space and the returned structure a is copied to the structure that gets a after calling the function? Ain't this be same without introducing the fancy term RVO?
Anonymous
No a good channel
Anonymous
can we read excel file in c
Asdew
Yes.
Anonymous
Yes.
oo thanks can you help me out.
Asdew
https://brechtsanders.github.io/xlsxio/
MᏫᎻᎯᎷᎷᎬᎠ
Delete the photo FAST
Dima
too late
Dima
/warn read the rules
MᏫᎻᎯᎷᎷᎬᎠ
Spare his life
Ashish Bhushan
😂😂
I_Interface
Fucking God, u have a good laptop and using the shit like codeblocks or something else. Is it so hard in install something normal?
Ashish Bhushan
And it's a very visible mistake btw...you have applied colon in place of semicolon
I_Interface
too late
AI works good.
Ashish Bhushan
Ashish Bhushan
I am also frok India
Ashish Bhushan
*from
I_Interface
It's turbo c++...for some reason indian schools and colleges make us use these
Nah, make it in Visual Studio or CLion/Qt Creator for Linux.
I_Interface
U have ur own head.
I_Interface
Don't make ur life more difficult with the shit from the past times).
I_Interface
you* your*
Fuck off, damn AI.
Dima
u looks like some kiddo, seriously
Anonymous
Lol which Indian uni is forcing u to use turbo C++ ???
Anonymous
Get outta there bruv
Dima
just like russia
Dima
visual studio 2005
Dima
at least not turbo stuff
Anonymous
Probably
Anonymous
Haha
Ashish Bhushan
Nah, make it in Visual Studio or CLion/Qt Creator for Linux.
I use visual studio ....i am just telling !!
MᏫᎻᎯᎷᎷᎬᎠ
Hi I'm from india palese lern me C++ quickly👨🏻‍💻
I_Interface
I use visual studio ....i am just telling !!
I was meant those guy, who posted the photo.