« first day (266 days earlier)      last day (4674 days later) » 
00:00 - 21:0021:00 - 23:00

Xeo
12:01 AM
Yea
VS's stdlib implementors have this bad habit of writing relational comparisions like if(max_val <= current_val)
yoda conditionals..
 
Ah
 
Xeo
lol
VS uses its predicate object for unordered_xxx also for hashing
I was pretty confused when reading this:
size_type _Hashval(const key_type& _Keyval) const
    {    // return hash value, masked and wrapped to current table size
>>>>size_type _Num = this->comp(_Keyval) & _Mask;
if (_Maxidx <= _Num)
	_Num -= (_Mask >> 1) + 1;
return (_Num);
}
damn it with VS using tabs
now I can't edit that message anymore >_>
 
12:26 AM
Interesting. The boost code in `functional_hash.h" is pretty clean...
Anyway, got to mosey
TTYL
 
Xeo
12:36 AM
@KerrekSB Well, they don't have to use the implementation reserved identifiers (or more like, they can't), so it is of course cleaner without all these underscores. Though, tbh, I don't even see them anymore
HOLY! We only got 5 users in here currently, there is something wrong!
 
 
2 hours later…
2:09 AM
 
 
1 hour later…
Heh, I like the other terminology: hingletons, mingletons, and fingletons.
 
^ My kind of girl :D
 
3:45 AM
For the purposes of detection, we are not interested in whether or not there is:
- a private constructor
- synchronized around the new instance logic
Why? We want to be able to detect badly written Singletons too.
 
If you need a singleton detector then there is probably something wrong with your codebase..
In my code I have two singletons and I'm gonna keep them just to spite all of you.
 
 
1 hour later…
Xeo
5:07 AM
 
Als
@Xeo: hello!
 
Als
5:24 AM
@JerryCoffin: Hello Jerry
 
Hi Als. How're you?
 
Als
Hey Jerry, doing fine, How about you?
 
Pretty fair, but getting a bit tired -- need to go to bed soon...
 
Xeo
To bed? Hell, it's 7:30 am here!
Oh, hi @Als
 
@Xeo Yup -- but 11:30 PM here, and I've averaged ~3 hours of sleep a night this week.
 
Xeo
5:31 AM
@JerryCoffin Hey, I know that! For me, that was the week where I did the task for my scholarship
 
Als
@Xeo: its early, You SO addict!!! I saw you playing around here about 7-8 hours ago too! :P
 
Xeo
Huh? I was awake the whole night, working on some stuff. :P
Also, how can I be an SO addict if all rep I got yesterday was a whooping 7 rep? xD
 
Als
@Xeo: :D
here's a chance to earn some
 
@Xeo Chat addiction yields no rep.
 
Als
0
Q: What is the difference between std::array & std::vector, When do you use one over other?

AlsI doubt this is a very trivial Q but I am a little confused here so as the title says, What is the difference between std::array & std::vector, When do you use one over other? I have always used and considered std:vector as an C++ way of using c arrays, So what is the difference?

@Xeo: I know you can collect some rep on that one :)
 
Xeo
5:35 AM
@Als Almost closed as duplicate, if it weren't for that std:: before the array :P
 
Als
@Xeo: It didn't show me any dups...
I have just realized i have hardly used std::array anytime! So much so i forgot it exists!
 
Xeo
@Als Well, it only exists since C++0x, so...
 
@Als vector needs a custom allocator to avoid dynamic memory allocation, array works that way out of the box. To me, that's the most important distinction
 
Xeo
Or rather, since Boost
 
Or rather, that's what guides my usage of one vs. the other most times
 
5:38 AM
@Xeo You just compared a pointer to an array inside the comments
 
Als
@Xeo: Aha boost I see, never used a lot of Boost
 
Xeo
@LucDanton Sue me.
 
@Als Turn in your C++ card, sir ;-]
 
Xeo
For the sake of the comment, it goes the same.
 
Meh that's not really the salient point. The distinction is in where the data is.
 
Xeo
5:40 AM
@Luc: For the sake of access comparision, it goes the same. :P
 
Als
@ildjarn: for not using boost?
 
Xeo
If you don't think of it that way, make a comment!
 
@Als Indeed
 
I'm not going to leave a comment explaining the difference between data with automatic duration and dynamic lifetime...
 
Als
@ildjarn: Yeah, I agree it is the most advanced c++ library but we all are restricted by what the projects we work on are allowed to use.
 
5:41 AM
@Als Fair enough. Personally, I go out of the way to avoid any contracts that don't allow Boost :-P
 
Xeo
int arr1[10];
int* arr2 = new int[10];
// ...
int i1 = *arr1;
int i2 = *arr2;
And yes, I know that an array only decays to a pointer et cetera, et cetera...
 
Als
@ildjarn: I would wish to go that way, but ahem one needs to do what pays for bread.
Geez, i thought i might get flaked for asking that Q, but i actually got some rep!
Tells me no Q is trivial..
 
Xeo
5:57 AM
Anyways, any help here ?
 
@Xeo Have you used it in a snippet?
I suggest the following: fill a signal object with functors, then call visit_each on it with a polymorphic functor that e.g. just prints out typeid(arg).name(). I'd try it myself but I'm not on the right machine.
 
6:33 AM
@Xeo It's a way of opting into runtime reflection, a la .NET or Java, on a type-by-type basis. Your question is vague -- what exactly are you confused about?
 
Xeo
@ildjarn Uhm... the function itself? 0:)
 
@Xeo No, specializing the function template for your type and its subobjects. Then, when you need to reflect one of your objects at runtime, you call the function
 
Xeo
Maybe I'm just so confused because
namespace boost {
  template<typename Visitor, typename T>
  inline void visit_each(Visitor& visitor, const T& t, long)
  {
    visitor(t);
  }

  template<typename Visitor, typename T>
  inline void visit_each(Visitor& visitor, const T& t)
  {
    visit_each(visitor, t, 0);
  }
}
Is the whole of <boost/visit_each.hpp>
So, um... where is the magic?
 
The magic is in your specializations for your types ;-]
 
Xeo
I think I need an example...
 
Xeo
6:56 AM
Anyone got an odd number of rep handy? I want to downvote this guy, but I have a nice multiple of 5.
 
There we go.
We really should rename the language to ++.
 
Xeo
xD
Well, yeah
After all, I bet it's one of the most used operators! Only beaten by new because it's used by so many noobs newbies.
 
Xeo
7:30 AM
Oh, Youtube gets more specific:
> Unfortunately, this video is not available in Germany because it may contain music for which GEMA has not granted the respective music rights.
 
 
2 hours later…
9:24 AM
The last message was posted 2 hours ago.
:-o
 
gg op no re
 
:-/
 
harhar
 
 
1 hour later…
sbi
10:29 AM
@MartinhoFernandes No, I don't!
 
sbi has added Martinho Fernandes to the list of this room's owners.
 
11:02 AM
@sbi yes you do :)
 
bitches
what's up?
recursively generate all permutations of a string
I wonder how people come up with such algorithms
reading about std's next_permutation
that's much clearer to me
 
sbi
@Nils To me it seems the easiest to come up with.
 
the recursion?
 
sbi
@Nils Yep.
 
nah it's not clear to me
I mean now that I see the solution I can print out everything and see how it works.
But I wouldn't be able to come up with such a sln
 
sbi
11:14 AM
@Nils Your algorithm picks the first slot and for every piece it puts there it calls itself on the rest of the sequence. What's easier than that?
 
humm well you also have to put it back afterwards
@sbi and now that you have a recursive solution you should be able to translate it to an iterative solution
 
I'm amazed at amount of people trying to code without having an ability to read.
2
(Not related to here, something else.)
 
sbi
@Nils Why should I when the iterative version is so much easier to understand?
@CatPlusPlus You just had to add that, right? :)
 
What renaissance? Ever seen a browser written in Java?
@sbi u mean the recursive? Well I would just wonder how to do it, since it's possible.
 
11:23 AM
@sbi Well, yeah, I don't want to get yelled at and flagged, and it's really something else. :P
 
sbi
@Nils It seems the term is becoming more and more popular.
 
@Nils Firefox is written in JavaScript, and JavaScript is like Java with Script, RIGHT?
 
puke script
 
sbi
Cool! Space shuttle software actually has a rollover bug! RT @newsycombinator Why shuttle won't be left attached to ISS http://j.mp/os02mm
 
11:32 AM
That's not cool at all! But terribly interesting to read nonetheless.
 
Well I guess the main problem is that Moore's law is poorly understood, he said that the number of transistors which can be placed inexpensively in to an IC is doubled every two years.
That doesn't mean performance is doubled every two years, especially not since DRAM is way slower.
If it would directly translate into performance then, maybe we could use Java like languages for everything.
 
 
1 hour later…
12:46 PM
who would want to?
 
Xeo
My reputation graph looks like some visualizer of a music track...
 
mine's definitely trending downwards
 
Xeo
You're still above me, I just don't get you: stackoverflow.com/tags/c%2b%2b/topusers
> 77,767 questions tagged c++
We're getting closer!
> Only 1 comment allowed per 15 seconds; timer reset.
 
yeah
I know exactly what you mean
 
 
2 hours later…
2:42 PM
@Nils Yes -- Sun's HotJava browser was written in Java. Long since discontinued and probably better forgotten though.
 
ok
I've definitely decided to use a lock
there's no way that I could do multiple parameter memoization atomically
 
cpx
3:23 PM
I was so close to get a fanatic badge for the second time :|
 
you can't
I've got 262 consecutive days, but only got fanatic once
 
cpx
oh i mean this was the second i failed :P
 
Can you get it twice?
I need to pay attention more.
 
no
damn
I wish I sucked more at C++ sometimes
 
cpx
first time, I had about 96 consecutive days and this time about 91.
 
3:29 PM
the only questions I have, nobody can answer
 
cpx
maybe i don't pay attention when the days come closer :(
 
> 643 days, 207 consecutive
I really should stop.
 
436 days, 262 consecutive
 
3:45 PM
I need a cool side project
solving projecteuler questions is not that motivating on the long run..
 
I think I did two or three before getting bored.
 
and I have like 0 ideas
ah maybe porting a nice game to c++
I love these games asahi-net.or.jp/~cs8k-cyu
do you people here have sideprojects?
 
4:07 PM
Depends on what you mean by side.
I have a lot of barely-started projects, contribute to an open-source one, and been on a webdev job since Tuesday.
 
things you do not for your employer or if you are self employed things you don't primarly make money with
 
Xeo
I have a huge amount of TMP crazy stuff
but that can't possibly be called a real "side project", can it?
 
My projects folder is huge.
 
tmp?
 
Template metaprogramming.
 
4:10 PM
ah well but I mean something like an app or something that common people might find useful
 
Xeo
Well, I find TMP very useful. :)
It teaches me pure functional style programming while still coding in C++
 
Lately I've been thinking about UI library for SDL. And few crazy game ideas.
 
Xeo
Ooooh, I would so love an OOP wrapper for SDL...
with clearly defined ownership semantics
 
never used sdl
 
Xeo
@Nils lol at the edit
 
4:12 PM
:)
 
Xeo
oh well, I reached my repcap hours ago, I'm off for today. See ya tomorrow o/
 
I even tried to write MUD once. Crazy.
Finishing projects is not my strong suit.
 
If you want to write something, write something that's fun for you.
 
why takes clang++ so much longer for small programs than g++
at least this is the case on my mac
using a newer version fixed this
 
4:38 PM
damn
apparently, I still don't understand rvalue references properly
 
@DeadMG My last gotcha was list-initialization.
 
4:52 PM
@DeadMG How do you figure?
 
I still don't understand how std::forward and such actually work
I used to think that it was Simples™ but apparently I just didn't get it
 
And speaking of the devil there might be a defect in list-initialization of references.
(not necessarily related to rvalue refs though)
 
I've been going back over the implicit templates proposals for C++0x
one of the problems that they had was that you would never know what the function returned outside of the TU that contained it
but since in "DeadMG++" there are no TUs, then that wouldn't be a problem for me
 
5:18 PM
Can a C++ implementation and its standard library implementation be decoupled?
 
in theory, there's no reason why you can't write your own Standard library with a copy of your operating system header
 
I wonder because typeid is a language feature and std::type_info is a library feature. But typeid requires type_info. Isn't that a dependency in the wrong direction?
 
however, most implementations will not take such a portable approach, and they will use implementation-specific hacks to obtain optimizations or work around compiler bugs
there are other examples there in C++0x with initializer_list and the range-based for
in theory, you could just do
namespace my_std {
    decltype(typeid(int)) type_info;
}
but, of course, that would just be std::type_info.
however, you certainly could replace nearly the whole library
 
5:33 PM
If first_middle_last_with_ampersandw_first_middle.test(Range("A" & i).Value) Then

pos = InStr(Range("A" & i), " &W ")

If pos < 1 Then
pos = InStr(Range("A" & i), " &H ")
End If

main_name = Mid(Range("A" & i).Value, 1, pos - 1)

secondary_name = Right(Range("A" & i).Value, Len(Range("A" & i)) - pos - 2)

secondary_last_name = Mid(main_name, InStrRev(main_name, " ") + 1)

Range("B" & i).Value = Trim(main_name)
Range("C" & i).Value = Trim(secondary_name & " " & secondary_last_name)

End If
the value of main_name is abc a def, yet it does not output that in column b
anyone know why?
instead it outputs the contents to the right of &H
its not making sense
 
No, it's not.
 
what on earth language even is that?
do not just dump code in the chatroom
 
Looks Visual Basic-y
 
go post an actual question, on stackoverflow, with an actual language and/or library/framework listed
 
this is the closest forum to vba. It's closer than php, javascript, and python at least
 
5:38 PM
It has awful variable names, and copypasta all over it.
 
actually I honestly thought I was in C# not C++
 
VBA? It's even worse than I thought.
 
Just because something is not C++ does not mean its bad
 
C++ is bad, too, don't get any funny ideas.
 
if you want to have an animation on your website, would you use c++ or javascript? Yet everyone says javascript is crap language compared to c++. Everything has its situation. Thats why they were invented.
 
5:40 PM
@JohnMerlino your point?
 
Er, what?
 
my point there isnt a bad language
 
Ok, I'm out of this thread, then.
 
if they are in wide use, they are not bad
 
That is so not true it's not even funny.
 
5:41 PM
really? I'd say the opposite. Every language i've ever encountered was bad
including C++ and Javascript
 
Only Lisp is perfect.
 
but stuff like VBA still achieve a whole new level of "bad"
anyway, why is the "badness" of languages relevant?
 
@DeadMG I think that std::forward<T>(x) is basically static_cast<T&&>(x), plus some TMP that prohibits template argument deduction. If you understand reference collapsing rules, that's all there is to it.
 
it doesn't really matter what language you prefer, but this is a chat, and it's not really suited for large code dumps. Feel free to post your code and ask your question here, but you'd likely have more luck on SO
 
@CatPlusPlus But is Lisp practical? :)
 
5:44 PM
@CatPlusPlus there's nothing perfect about a language so cluttered with parentheses'
It's elegant, sure, and powerful, but not perfect
 
@jalf You clearly never talked with a Lisper. :P
 
@CatPlusPlus sure did, but that doesn't make the language any more perfect
 
@DeadMG And std::move(x) is basically static_cast<typename remove_reference<T>::type &&>(x), if I'm not mistaken.
 
I ought to start using italics for sarcasm or something.
I don't like Lisp, anyway.
 
I kinda like it. It's neat. But not perfect, and not my preferred language
 
5:48 PM
@jalf So what language is perfect?
 
are you asking me?
Look at what I said a few minutes ago:
> really? I'd say the opposite. Every language i've ever encountered was bad
;)
If there is a perfect language, I've never encountered it
 
I just discovered that an "Identity class" can be used to simplify function pointer syntax:
template<typename T>
struct identity { typedef T type; };

typedef identity<int(int)>::type my_function;
 
I think Haskell comes quite close to being "perfect" in some sense. But it also seems to be mostly unpractical.
@StackedCrooked nice, but old
C++0x was originally going to have such an identity template, but I believe they took it out again.
 
@FredOverflow I just realized it today. It's very new for me.
 
identity<int*>::type p, q;   // yay, we can finally define two pointers with a single star!
3
 
5:52 PM
@FredOverflow I'd argue that an unpractical (isn't it *im*practical?) language is pretty far from perfection ;)
 
@FredOverflow typedef int* IntPtr;
 
but yeah, Haskell seems nice
I'm fond of ML myself
 
Haskell got the meaning of : and :: wrong, it's the other way around in Scala for example :-(
 
I read yesterday that in Haskell function arguments are not evaluated until used. That's quite lazy.
 
that's kind of the definition of a lazily evaluated language ;)
 
5:54 PM
@FredOverflow "Perfection is reached only on the point of collapse." (originally: "“Perfection of planned layout is achieved only by institutions on the point of collapse.” by Parkinson).
 
Lazyness allows for interesting patterns such as infinite lists.
Plus you get short-circuiting for free.
 
it's also a bit of a pain to do efficiently. But given a suitably smart compiler, and all that... :)
 
Damn, I got a sunburn on my left arm. I shall never leave my apartment again!
 
 
@FredOverflow do you know a way to expand the identity technique for creating typedefs to member functions? Since typedef int (Foo::*bar_function_t)(char x, float y); is such a handful.
 
6:00 PM
I am not afraid of other classes. They all inherit from the same base, don't they?
Admitted, this doesn't really work in the C++ chat :)
 
@FredOverflow and yet you won't let them touch your protected bits?
 
typedef identity<int (Foo::*)(char, float)>::type bar_function_t; maybe?
 
@FredOverflow I was hoping for a solution that would allow syntax like this:
identity<Foo, void()>::membertype
 
Not an expert on pointers to members, sorry. Never had a use for these beasts.
 
I'll make it an SO question then.
 
6:04 PM
I usually immediately wrapped them with boost::bind or something to make them less ugly.
 
same. I avoid pointers to members because I can't remember the syntax for them
 
Damn you, stupid C declarator syntax!
 
Hey why doesn't rand work with gcc?
at least in ubuntu
 
what do you mean?
 
 
6:10 PM
Well when I try to compile source that uses rand and srand it can't find it. I know I included cmath
 
they're not in cmath
 
Where are they?
 
stdlib.h/cstdlib, iirc
 
I also have ctime included
 
or, assuming C++0x, use <random> instead :)
 
6:12 PM
Use Boost.Random or the new stdlib one.
 
<tr1/random> for the TR1 version
 
rand is crap.
2
 
is there any alternative lol?
 
Well, what we just told you?
 
@tanner didn't we just give you 4 different alternatives? :p
 
6:13 PM
lol gotcha.
sorry about that
 
pick one. They should all work
5 alternatives, if you count <stdlib.h> and <cstdlib> as separate ones :)
 
Alright thanks for helping. I might be a little bit of a noob
 
np
 
And if you really want rand, then find an implementation of rand_r, it's a little saner at least.
 
You guys are awesome.
 
6:16 PM
yup!
 
Programming is difficult and its a good thing stack overflow is here haha.
 
Let's go shoppin'.
 
what?
 
Shopping is difficult for me because when I'm finally up and awake it's past closing time.
 
6:31 PM
Can't you buy groceries on the Internet?
 
@tanner there is also the Poco::Random class from the Poco C++ libraries.
 
Huh, so I guess its eany meany mieny mo time.
lol i just included stdlib.h
 
@FredOverflow I meant shopping for clothes. I guess I should try buying them online.
 
I don't think that would be a satisfactory experience.
What do you need clothes for, anyway? (Unless you have a webcam.)
2
 
6:46 PM
What do you need clothes for a webcam, anyway?
 
@StackedCrooked I wish I had been there for your question!
I answered on SO.
There's a funny rule that for a pointer to member type Sig T::*, if Sig is a function type then the resulting pointer type is a pointer to function member.
It's consistent and generic.
 
@LucDanton awesome!
Just tested it and it works!
 
That's why e.g. void() const is a valid function type in the proper context!
 
Madness.
 
Why did James delete his answer?
@LucDanton Could you include that explanation in your answer?
 
6:53 PM
On it.
 
@FredOverflow This good enough?
 
@LucDanton Quite formal, but I like that, of course :) I'd just replace "function member" with "member function".
 
template<typename T, typename Sig>
struct convenience {
    typedef Sig T::*type;
};

struct Foo {
    void bar() {}
};

void test() {
    typedef convenience<Foo, void()>::type mem_ptr;
    mem_ptr the_ptr = &Foo::bar;
    Foo f;
    f.*the_ptr();
}
^ Gives compiler error:
main.cpp: In function 'void test()':
main.cpp:29:16: error: must use '.*' or '->*' to call pointer-to-member function in 'the_ptr (...)', e.g. '(... ->* the_ptr) (...)'
make: *** [all] Error 1
 
7:01 PM
@FredOverflow I don't know if the emphasis works as well; it's supposed to contrast with pointer to data member.
 
that's because member function operator has less precedence than function call operator
 
i.e. add some parentheses
 
just like the error says, e.g. (f.*the_ptr)();
 
@StackedCrooked (f.*the_ptr)()
Slowness.
Besides, the error even tells you what to do.
Y u no read.
 
I did read it but was focused on the first "use '.*' or '->*' "-part. I didn't notice the brackets in the sample.
 
7:06 PM
@LucDanton But that's standard terminology. It's data member and member function.
 
So much for the nice symmetry
There, I spelled it out loud
 
C++ was never designed to be nice and symmetric :)
 
@FredOverflow As for order of construction and destruction, I think this actually was designed to be symmetric.
 
agreed
 
7:40 PM
Hey guys, I solved a problem on stackoverflow from last year, it was a really hard question with 0 answers and plusses for the question. Noone ever noticed my brilliant answer. Any surgestions ?
 
@tclausendk what question?
 
It was a question in sql how to join sets of multiple lines. Not really about C++
0 answers and from august last year. Was a hard question
 
oh ok
 
considering removing my answer and posting the question again. But it is kind of odd to answer your own question
 
can you give us a link?
 
7:48 PM
I even have an idea of how to improve it
 
Then edit it, don't repost.
 
heh, i have an idea, not an editor to test it. I only have one at work
 
Though the OP probably doesn't care any more, anyway.
 
exactly
 
If someone would need it, they'll find it.
 
7:50 PM
was hoping to get credit for digging up an old question
it is really one of the hardest things in sql
I also made an sql for sorting sql correctly. Also a big one
but found no question on it. Didnt even find anyone else doing it in sql
that one is a classic and i expected alot of hits when i looked
 
Would you like a ribbon?
 
what is that ?
whatever it is yes please :)
 
Wait, what.
Oh, right.
@tclausendk Pick one.
 
I pick the green one, the colour of hope
 
 
1 hour later…
8:57 PM
You get more rep from answering noob questions than solving hard questions.
 
yes, of course you do
there's a much larger audience
only people who get concurrency and C++ will be into my concurrent cache question, but anyone who's used the language for a day or two would be used to ++a++ questions, just for example
 
00:00 - 21:0021:00 - 23:00

« first day (266 days earlier)      last day (4674 days later) »