« first day (365 days earlier)      last day (4585 days later) » 

sbi
8:00 PM
@RMartinhoFernandes For the @Cat, apparently it's the floor.
 
Yes, we've got that from Australia.
 
Do you have the weird toilet water spinning direction too?
 
No, but we have weird toilet paper spinning direction, sometimes.
Usually when newbies are tasked with replacing the roll.
They never learn.
 
Over or under?
 
got to be over
 
8:03 PM
You mad.
 
> It has also been suggested that preference for under may correlate with ownership of a recreational vehicle or a cat.
 
over is easier to grab
 
@sbi Since when do we have a Wiki?
 
About a month ago.
 
tempted to just add "raeg" at the bottom
 
8:07 PM
6 hours ago, by cHao
vectors in Java are thread safe
> Being serious for a moment, "thread safe" is not a useful phrase. I recommend banning it from your vocabulary. People sometimes ask whether vector is "thread safe", and I have to explain that it supports the usual thread safety guarantees. They seem to be expecting something different - multiple threads simultaneously read/writing a single object. There are many problems with that, including two especially major ones:
> 1. Providing that is extremely expensive - every member function must take a lock. 2. Even if provided, that guarantee would be useless in practice. Consider this code: if (!v.empty()) { v.pop_back(); }
> Even if every vector member function took a lock, this code could not be executed on multiple threads (affecting the same v). The problem is that thread A could verify that v is non-empty, then thread B sneaks in and pops v's one and only element, then thread A tries to pop_back() on a vector that's empty. Boom. Locks have to be taken at a higher level than individual member functions.
 
Wohaa, calm down.
 
(taken from here)
 
that's why modern concurrent containers provide more atomic operations
like try_pop()
 
sbi
@RMartinhoFernandes No c'mon, you can do much better than that! Why are you named the Official Archiver?!
 
@DeadMG The discussion is about the merits of basic thread safety.
 
sbi
8:09 PM
Sep 9 at 12:18, by Cat Plus Plus
Maybe we should move them to a wiki-like stuff for easier updating?
Sep 12 at 14:26, by Cat Plus Plus
I did the wiki thing. http://loungecpp.wikidot.com/newbie-hints
 
sbi
Sep 1 at 17:29, by Cat Plus Plus
There are two choices of toilet paper orientation when using a toilet roll holder with a horizontal axle parallel to the wall: the toilet paper may hang over or under the roll. The choice is largely a matter of personal preference, dictated by habit. In surveys of American consumers and of bath and kitchen specialists, 60–70% of respondents prefer over. Despite being a trivial topic, people often hold strong opinions on the matter. Advice columnist Ann Landers said that the subject was the most controversial issue in her column's history. Defenders of either position cite advantages rang...
 
@sbi See, about a month ago.
 
sbi
@RMartinhoFernandes If you keep slacking this way, you will have to remove the R from your name again, you know?!
 
Hey! I'm not spending my time slacking anymore like I did for the past month!
 
8:17 PM
lol a whole article on toilet paper orientation
 
@cHao Not true at all. ArrayList (I assume that's what you mean by vector) is not thread safe under any definition of thread safe you pick that doesn't actually mean "not thread safe".
That's why Collections.synchronizedList exists.
 
@RMartinhoFernandes There actually is a Vector in Java where every method is synchronized. Not particularly useful, but it exists.
 
It even predates ArrayList.
 
Hey guys, if I have a world::Mat4 proj_mat; in my struct that I want to initialize it inside the ctor, I would like the Mat4 to be a reference at first or something, not a already created Mat4. How do I do that?
 
8:26 PM
You can't, not without a lot of machinery.
 
I will have to create a "dummy" Mat4 first
and then copy to it?
 
Can you show some code to better explain what you're trying to do?
 
Do you want lazy initialization or the ability to choose from composition and delegation at construction time?
 
namespace world
{
    struct Scene
    {
        world::Mat4 proj_mat;
        world::Mat4 view_mat;

        Scene(const float width, const float height);
    };
}
Scene ::
    Scene(const float width, const float height)
    {
        //  create the projection matrix
        proj_mat = world::set_perspective(1.0, 50.0, 180, width / height);
    }
 
Unrelated tip: use initialisation lists.
 
8:30 PM
You need world::Scene::Scene or a using directive / declaration, I think
 
right now I guess I'm first creating a Mat4 and then copy new values into it, the first creation seems stupid
 
Yes, that's what happens.
Was that the issue you wanted to solve?
 
@JohannesSchaublitb I have Scene.cpp in namespace world as well if that's what you mean
Not to create it first, instead the first time I create it would be the one I get from set_perspective
 
In that case:
Totally spot-on tip: use initialisation lists.
 
Scene::Scene(const float width, const float height)
    : proj_mat(world::set_perspective(1.0, 50.0, 180, width / height)
{}
That's what initialization lists look like.
 
8:32 PM
ah great
Didn't know you could use function in the init-lists
 
You can use any expression, as long as there's an appropriate constructor.
 
int&c = *(new int);
delete &c;
Is this valid or UB?
 
Valid.
But silly.
 
Silly indeed, but I'm actually surprised it's valid :)
 
If you take the address of a reference variable, it gives the address of the object it refers to.
 
sbi
8:36 PM
@ManofOneWay Every time you want a reference that can be set to "no valid object available", you want a pointer.
@KillianDS It's indeed valid syntax, but every workmate of yours would immediately gain the right to slaughter you on the spot when encountering this in your code. You have been warned.
 
@sbi I'd slaughter someone who does this also, it actually came up in another discussion and I'm trying to discourage it :P
 
Not just syntax. It also works fine at runtime. But yeah, chainsaws and psycopaths.
> Ah. In C and C++, subtracting arbitrary pointers is forbidden - they have to point within the same array. So a 32-bit implementation just needs to forbid 2GB+ arrays, and a 64-bit implementation just needs to forbid Galaxy-class arrays, and then the result of pointer subtraction will always fit in ptrdiff_t.
"Galaxy-class arrays" lol
 
Pointer arithmetic is silly, anyway.
 
Is whatever conversion this snippet came from interesting? I'm eager on any development regarding ptrdiff_t.
 
No, not very interesting. ("conversation" I assume)
What kind of development would you expect?
 
8:44 PM
Whether ptrdiff_t can hold any value resulting from pointer arithmetic or not. It's not clearcut and may depend on the actual Standard.
Or was that any array size? I'm not sure.
 
Oh, you mean the difference between arbitrary pointers?
 
tl;dr formally, are there corner cases to using ptrdiff_t where size_t is expected.
 
My understanding was that it only needs to be able to hold the values resulting from valid pointer arithmetic.
 
Yeah, that shouldn't be a problem.
 
sbi
@CatPlusPlus It helps with Quicksort.
 
8:46 PM
Oh wait.
 
sbi
@RMartinhoFernandes I don't plan to go anywhere tonight.
Oh, those anonymous downvoters! Who said something about chainsaws? Hand me one, please!
 
> Unless both pointers point to elements of the same array object, or one past the last element of the array object, the behavior is undefined.
But the same paragraph also doesn't require ptrdiff_t to hold all possible valid values.
Ah, but there's a guarantee later on.
> The type ptrdiff_t is an implementation-defined signed integer type that can hold the difference of two subscripts in an array object, as described in 5.7.
Whatever, I'm not really worried.
 
1
A: C++ vector size types

Alf P. SteinbachThe book you’re reading states that if you want to extract the size of a vector of type double (for example), you should do something like: vector<double>::size_type vector_size; vector_size = myVector.size(); Whereas in Java you might do int vector_size; vector_si...

Long discussion in comments.
 
I won't be using Galaxy-class arrays any time soon.
 
So yeah, I'm interested in any development but I'm not keen on doing the research myself :)
 
8:52 PM
Anyone did OpenGL with Haskell?
 
I did.
Why? You need that for class?
 
I wish.
No, I was wondering which library is the library to use.
 
I used HGL.
But I really have no idea if there's anything else, I did it just to show off.
 
And that's what matters!
 
Well, after the second CG class, a friend of mine that dislikes Haskell said something like "Look at that! Try doing this in Haskell!"
 
sbi
9:15 PM
C++ is the best language for garbage collection principally because it produces less garbage -Stroustrup
(We hadn't been wanking about how good our favorite language is in hours.)
 
Is this valid? template<typename T> enum class A<T>::X { Lulz };
 
Ouch.
Depends on A<T>::X: is it scoped or not?
 
template <typename T> struct A { enum class X; };?
 
9:19 PM
now we can actually define them out of class
 
> warning: 'enum A<T>::X' is an enumeration template [-pedantic]
Good job, you confused GCC.
 
it doesn't support this shiny new thing yet
 
How can you tell?
 
I've never thought of using an enumeration template. Seems sketchy.
 
9:23 PM
well you cannot do template<typename T> enum A { }; ofc
 
Yeah, I gather it's an extension as the warning is attached to -pedantic.
 
Standard C++11, in the case where the enum is just a member
there actually is no "enumeration template". it is just that the definition of the enumeration member is a template definition for a member of a class template.
 
Who put that warning in then?
 
i guess it's just slippy wording
the spec calls non-template member functions of class templates "function templates"
 
warning: wtf r u doin
2
 
9:26 PM
but only in a non-normative example code
@LucDanton BTW is it valid to say template<typename A, typename B> struct X; template<typename A, typename B> struct X<B, A> { }; ?
 
I'm going with no.
Except that GCC accepts it.
 
> When writing a specialization, be careful about its location; or to make it compile will be such a trial as to kindle its self-immolation.
4
Normative text in n3290.
 
standard artistry
spec also says
> Such artistry with names can be confusing and is best avoided.
 
> The argument list of the specialization shall not be identical to the implicit argument list of the primary template.
Wouldn't that prohibit your specialization?
 
9:38 PM
OMG, that really is normative.
 
> For partial specializations, the template argument list is explicitly written immediately following the class template name.
Nope.
Or maybe.
I'm not sure how the template argument list of the specialization (<B, A>) is not identical to the template argument list of the primary template (<A, B>), but the Standard isn't really explicit, is it?
 
@CatPlusPlus I was wondering the same thing not too long ago. Combining OpenGL with purely functional programming must be a real PITA.
 
any .NET programmers around?
 
unlikely, but go
What's on your mind?
 
I have a simple question. If I want to use SmtpClient Class (System.Net.Mail.SmtpClient) just to send simple email, do I need to configure SMTP on the server as well?
 
9:49 PM
Well, you need SMTP server somewhere to use SMTP.
It's kind of obvious.
 
hmmm.... okay..
It's possible to send e-mails just by using console and Telnet, so that was kinda confusing for me. Anyway, thank you!
 
@FredOverflow It's not pretty. It feels incredibly un-Haskelly.
 
What is a Haskell programmer's favorite food? Curry!
 
What is a C++ programmer's favorite dessert? istream!
 
10:03 PM
aww come on
istream? xD
hi btw
 
Yo room.
 
What is a C++ programmer's favorite song? The case is better than the catch!
 
uh?
I didn't get it :(
 
There is a song called "The chase is better than the catch".
 
Oh right, lol I didn't know
:(
@FredOverflow I assume you know of the OSI layers?
 
10:08 PM
I knew about them five years ago. Why?
 
@FredOverflow lol of course ;)
 
what?
 
I meant, of course you know of them
I have seen the diagram and understand that the bottom layer communicates to the top layer and so on, but I don't understand what these layers are
 
Abstractions?
 
A way to solve problem?
 
10:12 PM
For example, in the TCP/IP stack there is one layer whose job it is to guarantee that a package you send definitely arrives at the other end, even though the underlying connection is inherently unreliable.
Each layer does a different job at a different level of abstraction.
 
We have the physical->data link->network->tcp I understand that the layers are models to help us understand how it works. But what are they abstractions of?
Are they functions or something
 
Some layers are realized in software, others in hardware I believe.
 
@FredOverflow right. Like the physical layer.
 
The great thing about these layers is that application writers don't need to worry about all the low level details of network communication.
 
10:15 PM
@FredOverflow But if I don't understand the theory how would I know how to write the application? If I don't understand how tcp works
 
Just like a C++ programmer does not need to worry about what values should be stored in which registers.
@LewsTherin If you don't know how networking works, buy Tanenbaum.
 
@FredOverflow does he explain as if to a 2 year old?
Tanen tree? what is tanen
 
The book is very well written.
 
ok thanks dude :)
 
Tannenbaum = fir tree, but he is missing one n
Note that there are at least two newer editions of the book, but they usually cost a lot more. And networking fundamentals haven't changed that much in the last century ;)
 
10:19 PM
was that on purpose? I will check the library if they have it...or I fear...
 
I simply posted a link to the edition I have, that's all.
 
yeah, if the library has any editions that's fine.. otherwise
I wish I could do haskell
 
Tanenbaum is a classic. I would be surprised if your library doesn't have it. It's like the K&R of networking ;)
@LewsTherin You can. All you have to do is learn it.
 
We have some other dude Walter or William something. A most terrible book I must say. Too complicated.
@FredOverflow Easy for you to say :)
 
I'm a Haskell beginner myself :)
@LewsTherin Stallings?
 
10:23 PM
yes him!
@FredOverflow really? yeah right
@FredOverflow That dude is a terrible writer. He can't explain to save his life. Ugh
 
Really. I'm still at the "struggling with Monads" phase ;)
 
@FredOverflow that's very cool. I didn't get that far before I quit. Too hard.
 
I like a challenge, and I like a language that is not just "crippled C++".
 
Are you talking about Java?
 
;)
Let's just say once you know most of C++, there aren't many languages that offer you anything significantly different and exciting on the language level.
 
10:27 PM
What about C?
I guess that's C++
well C--
ah whatever
 
What exactly is exciting about C?
 
Compound literals!
 
Almost everything you could do in C, I'd rather do in C++.
Ah, C99. Variadic macros, yay!
 
Yeah, I figured you would say that
What is Compoud literals
 
structure literals
 
10:29 PM
@FredOverflow They're in C++11.
 
@LucDanton They are? Cool.
C++11 has uniform initialization which supersedes compound literals, I suppose?
 
lmao
 
@LewsTherin about what?
 
@FredOverflow Uniform initialization either requires writing a constructor or having aggregates all the way down I'm afraid. Although I'm still trying things out.
 
@LucDanton C99 compound literals also requires aggregates all the way down ;)
 
10:31 PM
Last attempt I couldn't make a perfect-forwarding constructor work with aggregates, very frustrating.
@FredOverflow Yeah, but std::tuple, by no being an aggregate, breaks that chain.
 
Is std::pair an aggregate?
 
Nope. At least it's consistent that way.
The problem by the way isn't really that those aren't aggregates, but that they don't use valued constructors. Perfect-forwarding constructors get in the way of aggregate syntax.
Well, at least they seem to be. I'm not 100% sure on those matters plus GCC might not be getting it right.
 
If I have void foo(std::tuple<int, char, float>), can I pass {42, 'a', 3.14f} to it or not?
 
Yes.
 
Then I don't see the problem.
 
10:34 PM
If you have struct A { int i; }; and void foo(std::tuple<A>); then you can't do foo({ 42 }); or foo({{ 42 }});.
 
Why not? :)
 
And I guess in your example you can't use use { { 42 }, { 'a' }, { 3.14f } }.
@FredOverflow What's the type of {{ 42 }}?
 
What's the type of {42, 'a', 3.14f}?
 
It's not an std::initializer_list<T> and hence the perfect-forwarding constructor is called.
 
@AlfPSteinbach ^ Windows 7 identifies g++ default output file [a.exe] as a Trojan.
 
10:37 PM
test.cpp:21:29: error: converting to 'std::tuple<int, char, float>' from initializer list would use explicit constructor 'std::tuple< <template-parameter-1-1> >::tuple(_UElements&& ...) [with _UElements = {int, char, float}, <template-parameter-2-2> = void, _Elements = {int, char, float}]'
 
@FredOverflow I just got that message too!
 
doesn't work for me...
 
Might have to do with explicit rather than std::initializer_list + perfect forwarding then. I'll take a look at the std::tuple constructors.
 
bar(std::make_tuple(42, 'a', 3.14f));   // fix
But I still don't understand:
3 mins ago, by FredOverflow
What's the type of {42, 'a', 3.14f}?
 
There is a valued constructor in any case, also marked explicit.
 
10:39 PM
Don't initializer lists have a single element type T?
 
Yeah, hence that syntax can't be one.
 
@FredOverflow it doesn't have a type by itself
 
Okay, so it's not an expression.
Must be some brace-init-foo or something.
 
Trying to set up an example where it's the other way around and problematic.
> warning: deducing 'T&& ...' as 'std::initializer_list<int>'
Is the kind of error we're looking after.
 
T&&...? That looks so cute :)
 
10:45 PM
bye @FredOverflow bye all
 
@FredOverflow Example. (GCC 4.5 on Ideone can't deal with the example, relevant error is on last statement of main.)
 
@LucDanton How about make_tuple<make_shared< bla >>? ;)
 
@FredOverflow This requires knowledge that the class internally uses a tuple.
 
Isn't that obvious from the signature of foo?
 
Although one of those classes actually has a constructor overload taking std::tuple to make that explicit.
@FredOverflow I have at least one variadic class template with perfectly-forwarding variadic constructor that doesn't use std::tuple internally. What's obvious here?
 
10:50 PM
I don't know if perfect forwarding is such a good idea from the perspective of a client. How is a client supposed to know what is okay to pass in and what is not if all he sees is T&&...?
 
Let me check my use case.
In two cases the variadic template is a heterogeneous container. So they're tuple-like (yet only one of them actually uses std::tuple) and what you pass are individual initializers.
More simply, how do you know what you're supposed to pass to the variadic constructor of std::tuple<T...>?
 
sbi
It makes no difference what city I'm in, the drinks cost the same and they do the same thing. Nice. :)
 

« first day (365 days earlier)      last day (4585 days later) »