« first day (708 days earlier)      last day (4466 days later) » 

13:00
:-D
Ell
Ell
ugh this is awkward to read atmail.org
is the scrollbar slanted too?
It was easy to read on my tabelet.
well, I'm supposed to be heading off to get my passport tomorrow and I've lost practically everything I was supposed to use to get it
Shit
13:05
no passport -> have to re-arrange going to Linz
Ell
Ell
go and find it :O
my parents are camping the living room, which is where they probably are
and I'd rather not go in there and start searching, because then they'd notice that I lost it, and I'd have to explain exactly why
Pwn those campers!
Ell
Ell
maybe it will teach them not to move your things
hasn't yet
13:11
so firefox android beta sucks. back to chrome
worse, it's raining, so they won't go out and walk the dog so I can have a chance to sneak in to the living room and search it
You need to accelerate and stop time temporarily.
what I need is to move out
What you need is search for the fucking thing and stop caring about pointless crap.
what, like, not getting into an argument with my parents?
13:19
Don’t be a pussy and get those documents.
You are like, 21 or something?
nearly 22
What argument?
well, my father would murder me for losing track of them
wats up hoes
Hoes?
13:26
hoes?
hose
sheep
anyway, it was pretty rude. (C-C-C-Combo breaker!)
Now i have to root this tablet.
Ell
Ell
13:41
@DeadMG you didn't lose track of them? They were moved by him? Or have you been telling porky pies?
@Ell Moved by my mother. But he doesn't see that point of view.
Ell
Ell
well what would you rather do, not have your passport soon or argue with your father?
eh, I might be able to get it if/when he goes to cook
This is a rather silly situation.
man
This is the best music ever.
Xeo
Xeo
13:58
Hm. Does template<class T> void f(T const&&) not accept lvalues?
FOLKS
@Xeo what is the point of const&&?
Question: is there something wrong with this code: liveworkspace.org/code/b8cf582526aa8e89e60b297f11988268 ?
@Xeo Think const breaks it. Not sure though, since const&& has absolutely no use whatsoever.
Xeo
Xeo
@daknøk I want to make any lvalue ref I accept const
13:59
@rubenvb Dangling reference.
Xeo
Xeo
@DeadMG That's what GCC 4.7.1 thinks atleast
@DeadMG Why does the compiler not warn about it?
@rubenvb How the hell does the compiler know you are passing in an rvalue at the callee side.
@rubenvb How the hell should I know? I'm not a GCC dev, wouldn't touch that shit with a ten foot barge pole.
@daknøk because it can see everything.
Xeo
Xeo
14:00
I have template<class T> void something(T&&); and also want template<class T> void const_something(T const&&) :/
Use a static analyzer for that stuff.
Xeo
Xeo
I can't go the obvious way with T const& simply, because I don't allow any temporaries (this is checked with a static_assert later on)
@daknøk It has to know
@rubenvb Actually. Not sure.
@Xeo At the callee side?
@Xeo Just take T&& and static_assert that T is not an rvalue reference.
Xeo
Xeo
14:02
@daknøk Oh, didn't see your stealth edit :P
Xeo
Xeo
@DeadMG T is never an rvalue ref when using universal references. If you pass a temporary, T is just T. And that's what I check, if any of the Ts in my pack is not a reference.
Ell
Ell
@daknøk s'okay
Xeo
Xeo
Also, think .begin() for general access and .cbegin() for ensured const access
@Xeo Point's the same.
const T&& is worthless
Xeo
Xeo
14:04
@DeadMG I know that
I just thought it was a handy way to get const values and still be able to filter temporaries out
nope
you'll have to filter temporaries manually
and T&& will still accept const values.
Xeo
Xeo
Now that I think about it, if T const&& would work like T&& does, when you pass an lvalue, T would be deduced as something& and you'd have something& const&&.. makes sense it doesn't work, after all
@DeadMG I do that already
@DeadMG Yes, but like I said, I want to provide a way to ensure const access
OK, GCC 4.7.2, Clang 3.1 and MSVC11 accept the dangling reference and compile fine on the casually strictest settings (-pedantic -Wall -Wextra and /Za for MSVC).
Xeo
Xeo
even if the user has only non-const lvalues handy
@Xeo Then static_assert that T is a const U&.
or just cast the damn thing
Xeo
Xeo
14:06
@DeadMG Still not what I mean
user784668
@Xeo Then do what you mean.
Xeo
Xeo
From a user POV: something(value); gives some access, const_something(value) gives only const access
3 mins ago, by Xeo
Also, think .begin() for general access and .cbegin() for ensured const access
user784668
@Xeo Try the [[do_what_i_want]] attribute or something.
Xeo
Xeo
lol
@Xeo Then cast it to a const reference.
14:08
4
A: Is there any limitation on the maximum size of array in c?

Seth CarnegieI am guessing that idata is a local variable. The problem is that local variables are stored on the stack (technically "automatic storage"), and the stack is much smaller than the 6400 megabytes you're trying to allocate on it. Allocating that much storage on it causes a stack overflow. Try uns...

what's with the upvotes?
user784668
@LuchianGrigore Idiots.
Xeo
Xeo
@DeadMG I don't think you can directly cast with universal references (same reason the deduction + collapsing doesn't work), but I have a pack and I'll just expand it through as_const(pack)....
@LuchianGrigore you seem to misunderstand my question in the comments to the const ref temporary question...
I meant to ask why there would be such an exception in the standard at all, looking at the circumstances.
@rubenvb dunno, I honestly didn't read the whole thing :)
I just knew of the exception from a previous question/answer.
:)
0
A: Is there any limitation on the maximum size of array in c?

FredOverflowHere is how you allocate and free a 2D array on the free store in C: unsigned char (*idata)[1400] = malloc(1600 * 1400); // ... free(idata);

yay 2D arrays in C :)
14:14
@LuchianGrigore lol ok. It's a useless limitation it seems. No big compiler respects it anyways.
@rubenvb but this - "Temporaries can bind to const references and they last until that const reference goes out of scope. In this case you bind it all the way through to Foo::m_x." is still wrong. I could get over the first part, but explicitly saying a member reference extends the lifetime of a temp is dead wrong.
@rubenvb What exception?
@DeadMG the one given here:
4
A: C++ return reference to temporaries or store them in objects

Luchian GrigoreBoth are safe, because you copy the values into x and y. The temporaries are valid until the end of the full expression. 12.2 Temporary objects 4) There are two contexts in which temporaries are destroyed at a different point than the end of the full-expression. The first context is when...

14:15
oh
@LuchianGrigore OK. It's just weird that the big Three don't do it that way :S
@rubenvb if it makes you feel any better, I was under the same impression until a couple of months ago. I'm pretty sure one of the guys in here pointed it out.
Possibly the robot
@LuchianGrigore I feel less dumb already :P thanks
whoah, just loaded over 1.5kg of lasagne into my oven.
oh, btw, I built GCC 4.7.2.
You can find it at the usual place.
(sounds mysterious, don't it?)
14:19
@LuchianGrigore I agree.
Ell
Ell
@BartekBanachewicz oh god I love that stuff
Don't worry, I already edited mmy answer. I hope it's more correct now.
@Ell i think my form is a bit too small. it caused kind of overflow
When I have a large program and I want to test one small function whether its return values is okay or not I generally comment out the main and write another main that runs that function only with given value. and I print debug statements instead of real debugging.

But is there any structured way of doing this ?
@NeelBasu unit tests
14:22
@BartekBanachewicz Yes I do BOOST_ASSERT but thats not enough
user784668
@Mysticial The real question is where's the "i" in "Alexander".
@NeelBasu do real unit tests
Xeo
Xeo
@rubenvb What way?
Its a complex algorithm and I don't always know what the expected output should be. I just want to trace whats going on underlying
@BartekBanachewicz with which one ?
This page is a list of tables of code-driven unit testing frameworks for various programming languages. Some but not all of these are based on xUnit. Columns (Classification) * Name: This column contains the name of the framework and will usually link to it. * xUnit: This column indicates whether a framework should be considered of xUnit type. * TAP: This column indicates whether a framework can emit TAP output for TAP-compliant testing harnesses. * Generators: Indicates whether a framework supports data generators. Data generators generate input data for a test and the test is run for ...
14:25
@BartekBanachewicz Yes But would that solve my problem ? e.g. tracing an algorithm on demand ?
@Xeo the temporary still exists, and I can print it. Maybe that's just undefined behaviour being "nice" though.
Xeo
Xeo
It is
Since the memory wasn't reused, you can still find the value there
user784668
@rubenvb It's not the temporary, it's a nasal demon.
@rubenvb not nice. When UB works, it's never nice. What would be nice is if it crashed.
hence the quotes around ""nice"".
14:31
@rubenvb Temporaries' lifetimes are only prolonged by binding them directly to a local reference. You didn't do that, hence the temporary is destroyed at the end of the full expression.
By the way, does lifetime extension also work for global references? :) I guess so, but the question has never entered my mind until now.
user784668
@FredOverflow Check it.
user784668
@Fanael Yup, seems to work. Oh, we have basically the same test program, just with different names :)
@Fanael globals are initialized/destructed before/after main respectively.
user784668
@rubenvb It's a temporary, not a global.
14:35
It's a global reference initialized with a temporary, hence lifetime extension seems to happen.
@Fanael the temp is bound to a global const ref, so it lives as long as that reference, which is global, thus, after main it dies.
Now as we all just saw demonstrated, a compiler doing something is not at all any proof of correctness.
user784668
@rubenvb Citation.
Xeo
Xeo
@FredOverflow It's not really about "local" refs. Any reference-to-const / rvalue ref will extend the lifetime of a temporary, but the standard describes special cases until when the lifetime is extended.
@Fanael I said what was happening, not that it should happen.
@Xeo I bet 100 dollars that it doesn't work for parameters and members. (There is no need for parameters, anyway.)
user784668
14:36
@rubenvb So what you said is irrelevant.
Xeo
Xeo
struct X{
  int const& x;
  X() : x(42){} // 42 is bound to x, lives until end of ctor
};
@Fanael not less relevant than GCC's result for that code.
Xeo
Xeo
@FredOverflow It does
There are no conditions on life-time extension, only until when they're extended
@Xeo No, it does not. Normally, a temporary lives until the end of the full-expression. If you call a function and pass it a temporary, of course you can access the temporary through the parameter inside the function, because the full-expression is not done evaluating yet. No lifetime extension going on there.
0
A: Why is 11==011 returning false?

mjgpy3The following #include <iostream> using namespace std; int main() { cout << 11 << endl; cout << 011 << endl; return 0; } Produces the output: 11 9 Exactly why that is, I haven't a clue, but it does explain why your condition returns false.

14:40
@LuchianGrigore too friggin' easy. I knew that too :(
I meant the "Exactly why that is, I haven't a clue, but it does explain why your condition returns false." part. Which was edited out now. :))
user784668
@FredOverflow As far as I understand the standard, it doesn't differentiate between local references and global references in this context.
user784668
@LuchianGrigore I was tempted to upvote him for these words.
14:42
@Fanael you and I have different standards then :)
Hey, why'd you edit out the "Exactly why that is, I haven't a clue, but it does explain why your condition returns false." part? That was the only difference between your answer and the correct one... — Luchian Grigore 1 min ago
@DeadMG don't endorse that shit man!
because it's epically wtf
not everyone gets your sarcasm...
what sarcasm?
Because he does know why :P — DeadMG 3 mins ago
what's sarcastic about that? he clearly does, because he edited his answer with it.
14:47
:3 nom nom nom
Xeo
Xeo
> A temporary bound to a reference parameter in a function call (5.2.2) persists until the completion of the full-expression containing the call. (§12.2/5)
@DeadMG he does now. By the same reasoning, I could add an answer stating IDK and wait for a correct one. Then I'd just edit mine... WTF?
Xeo
Xeo
@FredO ^ as a special case to when a temporary is destroyed at a different time than the full-expression
-1
A: Initial Value of Dynamically-Allocated Memory in C

Lews TherinTo answer your question no.. But there is a way to set default values. Try: int *arr = new int[SIZE]() ; The above is C++ standard but may not work on all compilers. The safe bet would be to use a loop and initialize it to a default value of your choice. for(int i=0; i < SIZE; i++) { arr...

So you tried C++ and it wasn't working out for you. That's not unusual. But why the heck did you think to try PHP next? It's like trying to learn classical guitar and giving up for Guitar Hero. — joshin4colours 19 hours ago
14:49
What's up with people today? :))
That's epic :D
@Xeo How exactly does "persists until the completion of the full-expression" differ from the standard behavior of being destroyed at the end of the full-expression?
Xeo
Xeo
@BartekBanachewicz I jelly. :(
@Xeo It's surprisingly easy to make
Xeo
Xeo
14:51
@FredOverflow I wondered about that too, at first, but I think they special cased it for default arguments that are bound to references.
Xeo
Xeo
I think something like int const& f(int const& i = 42){ return i; } void g(int const& i){ std::cout << i << "\n"; } void h(){ g(f()); } will not invoke UB
> A temporary bound to a reference member in a constructor’s ctor-initializer (12.6.2) persists until the constructor exits.
here's the text for the member reference btw
@Xeo Default arguments are created by the caller, anyway, right? So again, it's not really a special case if you think about it ;-) Not 100% sure though.
Xeo
Xeo
Should be
@Xeo It will.
Xeo
Xeo
14:54
@FredOverflow But yeah, in the end, I'm as confused as you on why they made that a special case
@DeadMG When exactly do you think the 42 will be destroyed?
when f returns#
Xeo
Xeo
A default argument is no different from a formal argument by the caller, so why should it be destroyed earlier?
Xeo
Xeo
And how could f handle whether it was passed its own default argument or something else?
14:59
@FredOverflow Are you srsly trying to use the behaviour of one implementation to argue that it's not UB?
because "Appears to work" is fine UB.
I am not looking at the temporary, I am just printing out where I am in the control flow. And it appears inside g, the temporary has not been destroyed yet, because the output from the destructor comes last.
so, it appears that in that version of GCC with those compiler flags on this day on that operating system, it appears to work
Also, g++ 4.6.3 gives the same output on my computer.
@DeadMG Also, Xeo's argument makes a lot of sense. And you haven't provided an argument yet.
true
all I'm saying is that ideone's output is irrelevant
Well, maybe we can get some Microsoft people to test the code on their compilers.
15:03
the outcome of which would be equally irrelevant
Anyway, we already have the relevant standard quote:
> A temporary bound to a reference parameter in a function call (5.2.2) persists until the completion of the full-expression containing the call.
@LuchianGrigore I see you still disagree ;)
I simply used ideone to test Xeo's claim. I know it doesn't prove anything, but it gives me a warm, fuzzy feeling.
@LewsTherin what's the value of x after int x = 0;?
Obviously 0..
15:05
@LewsTherin what if the compiler doesn't support int?
But if I was to write my compiler I could decide that x should be 1.
@LewsTherin then you wouldn't be implementing a C++ compiler.
@LuchianGrigore Then I would use some integral type.
@LewsTherin I don't think you could. Not for a C++ compiler.
@LewsTherin really. If int x= 0; wasn't supported, you wouldn't replace the compiler?
1
A: Initial Value of Dynamically-Allocated Memory in C++

Lews TherinTo answer your question no.. But there is a way to set default values. Try: int *arr = new int[SIZE]() ; The above is C++ standard but may not work on all compilers. The safe bet would be to use a loop and initialize it to a default value of your choice. for(int i=0; i < SIZE; i++) { arr...

Note I only downvoted after you suggested the for loop.
Xeo
Xeo
15:07
0
A: C++11 - What's the best way to iterate over two or more containers simultaneously

XeoFor your specific example, just use std::copy_n(contB.begin(), contA.size(), contA.begin()) For the more general case, you can use Boost.Iterator's zip_iterator, with a small function to make it usable in range-based for loops. For most cases, this will work: template<class... Conts> a...

I still say it depends on the compiler. For example, yesterday I found out compound literal is perfectly valid in C99 but not in MSVC
Should I ditch MSVC then?
Xeo
Xeo
@DeadMG ^ btw, for why I tried the T const&& :/
Even a memset would have been better.
user784668
@LewsTherin That's because MSVC doesn't claim to support C99.
Xeo
Xeo
@LewsTherin MSVC implements C89
user784668
15:07
@Xeo All significant C compilers do. The point is MSVC supports only C89.
C89 is C, so all C compilers do.
0
A: Initial Value of Dynamically-Allocated Memory in C++

FredOverflowIf you use vectors instead of arrays, you will get an initial value of 0 for all elements: std::vector<int> v(50); If you want a different default value, you can specify one: std::vector<int> v(50, 42); An additional benefit of vectors is that you don't have to manually release ...

The earlier ones are proto-C and are even worse than C89 so screw that.
Since nobody mentioned vectors yet...
@LewsTherin if you believe all our answers should be followed by "this might not work with all compilers", then ok. If not, there's no point in continuing this discussion.
15:08
@LuchianGrigore The for loop is still valid, sure it isn't as efficient as memset but it works.
@LewsTherin as long as value-initialization is part of the standard, and C++ is regulated by that standard, and that standard clearly states the concept of value-initialization, there's no point in discussing further
@CatPlusPlus Do you like C89 or C90 better? ;)
That was not on the list of choices!
user784668
@CatPlusPlus I can imagine a compiler supporting only C99 (int restrict = 0?).
15:09
Sure, you might point out that a borland compiler from the 70s didn't support it, but don't suggest a for loop for that task, just because you had a bad experience once.
But that's like asking if you prefer to die by being set on fire or frozen.
Hm... I guess I would just like to fall asleep and never wake up again. What language would that be? ;)
user784668
@LewsTherin A decent compiler will detect that the loop is in fact memset and optimize it accordingly.
user784668
@FredOverflow Python.
Python 2.x or Python 3.x? ;)
Xeo
Xeo
15:11
@Fanael Err... what?
You'd need some pretty sophisticated optimizer for that, I think
user784668
@FredOverflow 1.5.2
user784668
@Xeo I think I've seen MSVC and LLVM doing that.
Why did nobody suggest std::fill or std::fill_n?
user784668
@FredOverflow Because <algorithm> is optional.
What do you mean, "optional"?
15:13
@LuchianGrigore Fair enough.
user784668
@FredOverflow An implementation may not support it and still be conforming.
Really? Where does the standard say that?
user784668
@FredOverflow 17.6.1.3/2
user784668
> A freestanding implementation has an implementation-defined set of headers. This set shall include at least the headers shown in Table 16.
Xeo
Xeo
Who the fuck ever talks about freestanding implementations, seriously.
user784668
15:16
<algorithm> is not included in table 16.
Ah, I guess that's for embedded systems and stuff.
user784668
@Xeo Language lawyers.
Boring people with no lives.
lol
And do we have a life?
Sure. We chat therefore we are.
3
15:22
lol
success! I ninja stealth retrieved my passport form whilst my evil father was in the kitchen
Xeo
Xeo
And... why did you need to "ninja stealth retrieve" it?
because my mother moved it
@DeadMG And if your father finds out, will he say "You bad dog?"
15:24
@CatPlusPlus related gif
and if my father discovered that I no longer had possession of it, he would ensure that I suffered greatly
@Xeo Because it was IN THE LIVING ROOM. Can you imagine that?
Xeo
Xeo
wtf
@CatPlusPlus Maybe his family has a special room or inanimate objects?
Xeo
Xeo
@FredO: Boo, I forgot only 0 was special as an initializer to an array :|
15:31
How about int* arr = new int[42]{1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337};?
Xeo
Xeo
Err... yeah... no.
Why not? :)
user784668
@FredOverflow I hope you typed 42a1337, <Esc>.
This is painful to read.
This is painful to think about.
I hate you.
No, I typed "1337, 1337" and then copied the ", 1337" part and pasted it 40 times :)
I guess everybody is checking for off-by-one errors now? :)
user784668
15:34
@FredOverflow Slow, but still better than typing 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337.
right
now I need to find my original passport, which I seem to have done a smart and misplaced
user784668
@FredOverflow I checked with set tw=6 | normal! gqq | echo line('$').
user784668
@FredOverflow You're lucky it evaluated to 42.
0
Q: LaptopSpeakers donot work

user1692520My laptop speakers make sound when I power on the laptop but in windows it doesn't make any sound and I can hear nothing but when I plug in any headphone to it the sound comes out from headphone. Till now I've changed the windows and even reinstalled sound drivers. please help me what can I do :(

Apparently we are technicians
15:51
@FredOverflow intercalate ", " $ take 42 $ cycle ["1337"]
Oh wait.
user784668
@daknøk You forgot take 42.
What @Fanael said :)
user784668
@FredOverflow You fail. Twice.
@LewsTherin he should recompile the kernel
15:56
@daknøk why not ...$ repeat "1337"?
user784668
@Mechanicalsnail Because repeat is 2.39% slower.
@Fanael 92 percent of statistics...
user784668
@Mechanicalsnail 100% of sarcasm.
Apparently today is National Day in Saudi Arabia—and also Celebrate Bisexuality Day.
user784668
15:59
Is 239 prime?
$ factor 239
239: 239

« first day (708 days earlier)      last day (4466 days later) »