Do you use C++11

Pages: 12345... 8
Framework wrote:
I use the latest GCC compiler, so I don't know where you get "non-compliant compiler" from.
How did you read "MSVC" and then think "GCC"?
closed account (zb0S216C)
What?

Wazzak
How are std::begin() and std::end() useful? I can't imagine a scenario where passing an object to a generic function that does nothing but call one of its methods is preferable to just calling that method directly, unless the function is a friend of the object and the method is private, but if the method is private, you shouldn't be calling it anyway In both cases you need to have access to the object, so I don't see how it could ever be useful.
How are std::begin() and std::end() useful?

They also work on arrays.
Last edited on
std::arrays or stack arrays?
Never mind.
Last edited on
^ This. Finally in C++ we have a generic way to get the beginning and end iterator on all iterable containers (besides naked pointers to the first element in a dynamic array, of course).

Framework wrote:
Err... no.
Are you sure? This looks pretty obfuscated to me:
1
2
3
4
for(std::set<SomeType::ThatType>::const_iterator it = mycontainer.begin(); it != mycontainer.end(); ++it)
{
    *it += blah;
}
Whereas this looks obvious:
1
2
3
4
for(auto &v : mycontainer)
{
    v += blah;
}


Framework wrote:
Do you see any sarcasm tags in my last reply?
No, but what you said was very seriously making me think you were being sarcastic. I've never seen the lazy-programmer argument used seriously before.

Framework wrote:
I disagree. Not once have I ever deemed their use valuable.
.begin() and .end() don't work on arrays.
Last edited on
closed account (3qX21hU5)
I've used std::begin and end on stuff like this. That is the only usefullness I have found (IE Working with Arrays)

1
2
3
4
5
6
int main()
{
    int myArray[] = {1, 5, -1, 6, -54, 155}

    std::sort(std::begin(myArray), std::end(myArray)
}
^ This. No more hackery, tracking size, adding pointers, or other crap. And the array can be swapped out for an STL container without changing any other code.
Last edited on
closed account (N36fSL3A)
I don't find 95 percent of the standard library useful actually.

*goes to bunker for protection against bashing*
closed account (3qX21hU5)
You also have said you haven't ever used much of the STL...

So how would you know if something is useful if you have never really used it? But that is all I will say don't want to be baited into another troll argument.
Last edited on
closed account (N36fSL3A)
It isn't a troll at all. I just never really found use to use most of the functionality of the Standard Library.

I used to use cmath but people said it was slow, and I never really used it again because I found other ways to solve problems.

I mean every time I want to learn a part of the Standard Library I read up on it and people say its slow, it more prone to memory leaks, etc.
@Fred

That is because you have never developed any commercial software for the real world.
closed account (N36fSL3A)
Give me an example when to use 10 things from the std library.
std::vector and std::map are used for almost everything, you use std::cout and std::cin for I/O, then there's std::ifstream and std::ofstream for files, you have to use std::istringstream and std::ostringstream for converting strings and numbers (or the new functions introduced in C++11), and don't forget std::string and std::sort. That's ten things I use all the time - please don't tell me you don't see a use for them.
Fredbill30 wrote:
I don't find 95 percent of the standard library useful actually.

*goes to bunker for protection against bashing*


Fredbill30 wrote:
Give me an example when to use 10 things from the std library.


Fuck off!

Back on topic, garbage collection?
I remember reading about some GC partial interface thing, but there's no actual GC in C++.

http://en.wikipedia.org/wiki/C%2B%2B11#Allow_garbage_collected_implementations

Here are some C++14 stuff, and I didn't spot any mention of garbage collection.

http://www.meetingcpp.com/index.php/br/items/a-look-at-cpp14-papers-part-1.html
http://www.meetingcpp.com/index.php/br/items/a-look-at-c14-papers-part-2.html
http://www.meetingcpp.com/index.php/br/items/a-look-at-c14-and-beyond-papers-part-3.html
http://www.meetingcpp.com/index.php/br/items/a-look-at-c14-and-beyond-papers-part-4.html

L B wrote:
Whereas this looks obvious:
1
2
3
4
for(auto &v : mycontainer)
{
    v += blah;
}



Perhaps if you didn't use auto.

And I have to repeat what I think chrisname already said, introducing a new keyword such as foreach would've been the better thing to do, as opposed to recycling for and giving it a new syntax.
Adding a 'foreach' keyword would have broken a lot of code (people implementing their own foreach)
Edit: also, how would not using auto make it look more obvious?
Last edited on
Lachlan Easton wrote:
Adding a 'foreach' keyword would have broken a lot of code (people implementing their own foreach)
Only if they are using namespace std;

Edit: also, how would not using auto make it look more obvious?
It's not always obvious what the type will be. I think range based for's would only be an issue if the old syntax was deprecated.
Only if they are using namespace std;
Or if they implemented their own foreach function/variable/class.
keywords do not reside in namespaces.
@cire and Lachlan Easton
Good points, I didn't think that one through.

Edit: Wouldn't it have also been an issue introducing other keywords such as constexpr?
Last edited on
Pages: 12345... 8