« first day (458 days earlier)      last day (4491 days later) » 

2:00 PM
0
Q: Implementing incremental array in C++

JKAUSHALYAI want to implement an array that can increment as new values are added. Just like in Java. I don't have any idea of how to do this. Can anyone give me a way ?

Incremental arrays, lol.
 
> I cant use std::vector this is for my uni works.
Sigh.
> For example in Accelerated C++, you learn about classes and stuff by implementing a std::vector.
 
C++ courses are worthless.
 
This is cool.
I shall recommend Accelerated C++ more.
 
Why learn dynamic arrays by themselves, if you're not going to ever need them in raw edition?
Also, I hate exams.
 
@CatPlusPlus dynamic arrays as in C99 varlength arr[]?
 
2:07 PM
No, as in std::vector.
 
@CatPlusPlus parhaps I missed something, but I am fairly sure that even in Java, if you make an array say float[] t = new float[n] trying to access t[n] will give you an index out of bounds exception rather then just expand the array
 
Xeo
0
Q: refer to section 10.4.6.3 "coping members" of TC++PL 3rd edition

10001001058what does this statement means "A default copy constructor or default copy assignment copies all elements of of the class .If this copy cannot be done,it is an error to try to copy an objet of class " for ex class unique_handle{ unique_handle(const unique_handle&); unique_handle&...

Wtf
-1
Q: refer to section 10.4.4.1 "copying object" of TC++PL 3rd edition

10001001058class table{ name *p; int i; public: table(int j=15){p=new name[i=j]} //constructor ~table(){delete[]p;} } void h() { table t1; table t2=t1; table t3; t3=t2; }` Bjarne wrote array created for t1 will be deleted 3 times as array created for t1 appears i...

 
great,
0x0000000000418eb9 in bool_vector_multiply<std::_Bit_iterator> (
connect_begin=...,
connect_end=<error reading variable: Cannot access memory at address 0x10>,
neuron_begin=..., neuron_end=..., result=@0x600e60: 0) at chaos.cpp:56
56 result += (*connect_it) * (*neuron_it);
aaaaargh
 
Xeo
Wut?
 
"Cannot access memory at address 0x10" Ooops, bad pointer.
 
2:09 PM
yah duh, it's a vector<bool>
crap
I can do if's instead maybe
 
vector<bool> sucks.
 
if(*connect_it && *neuron_it) result+=1;
 
Wait, that's derp.
See, that's why I hate exams. You don't sleep and you can't think.
 
lol
@CatPlusPlus You don't sleep because you don't want to.
 
No, I don't sleep because I don't have time to.
 
2:11 PM
The only reason I don't sleep before exams is when I'm afraid of not waking up in time.
Which has happened countless times before.
 
For the last week I've been sleeping during the day.
Waking up at around midnight and exams exams exams.
 
Als
Good thing about me is I can sleep anytime and get up any time!
 
I'm starting to think vector<bool> is the reason for my headache
 
@Als me too. any time I am sat around for a while, my body sees it as a chacne to get some sleep in
 
Als
@thecoshman: Lucky us ;)
@rubenvb: Err...Indeed that one is a problem!
 
2:14 PM
@thecoshman If I get inside a moving vehicle, I am bound to fall asleep. And then I have to walk back like a kilometre or something to get home from the bus stop where I woke up.
 
@Als indeed, it is rather nice being able to go for ages with out needing sleep, then being able to lie down for an hour and get back up
@RMartinhoFernandes lol, I am paranoid on buses for that exact reason. Though if I am with some one who is going to keep an eye out, I fall unconscious in minutes
 
Well, when I was working that was my daily exercise: walking back home from the bus stop at the end of the day.
Sometimes I had to walk back to work in the mornings too.
 
Als
@RMartinhoFernandes: I always walk till the place my company bus picks me up
that is a good 15-20mins away from my place
 
Company bus. What luxuries.
 
Als
I pay for it :)
 
2:21 PM
technically that's not a company bus. It would only be a company bus if you thought you didn't pay for it
 
Als
Technically, its an employee + company driven bus, Employees pay some subsidized amount and the company fills in the rest.
 
I have the same set up, ten minute walk to 1euro bus (need to learn the alt code for euro sign)
 
@thecoshman Alt+Shift+e?
or Alt Gr+E on an azerty
 
nope :(
 
euh sorry ctrl+alt+e
on an azerty
 
2:23 PM
@rubenvb It's also AltGr+E on qwertys that have it.
 
alt-f4
 
@RMartinhoFernandes I didn't know qwertys had Alt Gr keys
 
Als
Im fuckin bored!
 
ctrl+alt+e = é
 
2:25 PM
Is there any significant disadvantage to declaring variables in a loop which will be executed throughout the program ?
 
@rubenvb Mine has.
 
@angryInsomniac How do you "execute a loop throughout a program"?
 
@StackedCrooked i.e. the loop is the program .. it just keeps running all the time
 
Als
@angryInsomniac: Code speaks louder than words, So code please
 
If you need those variables in the loop then I guess you have no choice but to declare them.
 
2:28 PM
@Als Women speak louder than code.
 
I could declare them outside the loop and just change their values in the loop
 
So, women please.
 
Als
@RMartinhoFernandes: You very well know theres none around here!
 
@angryInsomniac Generally it's better to declare them inside the loop.
 
@RMartinhoFernandes Sorry .. cant oblige you there :D
 
2:29 PM
@angryInsomniac Cut its legs off. I bet you it'll stop running
 
Minimize scope.
 
Maximize profits.
 
@rubenvb Oh come on .. :) you gonna make terminology jokes now ? :D
 
Als
I have been away a few days and goddamn this room actually started talking about c++, what a shame!
3
 
@StackedCrooked Hmm .. well that simplifies things :) Thanks
 
Als
2:30 PM
huh Was that an actual discussion?
I was tempted to ask what are the variables? What do they do? Do they need to be initialized on every iteration?
It was swoosh..
 
Is there any way to abuse SFINAE to write one template function that does different things depending on the type?
 
Als
dang I am slow
 
@rubenvb You mean, an overloaded function?
 
@RMartinhoFernandes well, I can't have three overloads for float, double and long double and have one template for integer types.
 
2:32 PM
@Als Sometimes it's better not to know :) It saves you from the horrors.
 
that's inconsistent
 
I hate inconsistent
 
Favor overloading over specialization.
I don't remember where I read that though.
 
Als
@StackedCrooked: Yeah It seems I have become paranoid to say anything about any code lately without seeing it.
 
@Als The variables are varied , some are primitive type some are not , I was just looking at my code and wasn't sure weather stuff which does not need to retain its value over all iterations (i.e. variables that just act as temporary buffers for calculation and manipulation) should be declared inside or outside the loop
@Als You asked :D
 
"Whether".
 
@angryInsomniac you know you could've benchmarked both cases in the time you spent here on this subject?
 
Als
Grammer Nazi
 
@RMartinhoFernandes Yeah yeah
 
Als
fuck thats fast even for a bot!
 
@rubenvb Nope ... i couldn't have .. significant places where I need to make changes !
@RMartinhoFernandes 1 mistake and you're all up in my business :P
 
then you're very much oversimplifying the situation to us, and any answers we could give will not be guaranteed to be at all accurate
 
@RMartinhoFernandes is there a little rhyme to help remember this one?
 
@Als I have The Oatmeal on speed dial. I once got 10 upvotes on an answer that linked to the semicolon comic.
 
Als
2:35 PM
@angryInsomniac: If you haven't detected yet that this piece of code is a bottle neck then declare them inside the loop, use them and then forget about them as quickly as you used them.
 
@thecoshman A kick in the hemorrhoids should get the point across.
 
@RMartinhoFernandes ¬_¬
 
@Als hmm , ok !
 
Als
Oh I answered Most Vexing Parse two times today!
 
Learning how to write phonetically identical words by rhyme doesn't work.
Hemorrhoids however..
 
Als
2:37 PM
@angryInsomniac: Pre-Mature Code optimization is a sin unlike Pre-marital sex
 
You know, a month ago I'd never have thought that I would end up knowing how to use kerberos
now, I wish I didn't know
 
kerberos rings a bell, butI have no idea what it is
 
can I do unsigned wchar_t?
 
@rubenvb No.
 
Als
some protocol
if i remember correctly
 
2:38 PM
of course, the really painful part is interoperating between two different kerberos implementations, and a layer of 3 other libraries built on top of them
 
There's only one wchar_t. Fortunately.
 
@DeadMG If what @jalf says is true, then you don't want to know.
 
@Als Possibly :) but this isn't premature , the thing is almost complete I'm just looking to iron out the kinks
 
yeah, big complex authentication protocol
it's pretty clever and powerful and all, but a pain to work with
 
@RMartinhoFernandes well, if not, I could've overloaded my i/o for unsigned only, which would have gotten me a distinct char16_t on MSVC
 
2:39 PM
@jalf from what I can gather, it's more like a candy-floss definition
 
Als
Yeah I fixed one bug in an http stack once ..something related to kerberos
 
but seeing as MSVC sucks anyways...
 
Als
long time ago
 
@Als I don't even want to know how those to are related :O
 
@rubenvb Distinct from int16_t (aka short)?
 
2:40 PM
@RMartinhoFernandes yes
you can overload on signedness, can't you?
 
what really sucks is that the more I learn about it, the less our code works
 
Oh wait, unsigned wchar_t, I see.
 
even if I don't actually change anything in the code
 
0
Q: Wrapping C++ template function

MikeI try to wrap a template function with the help of GNU's linker wrap option. The code looks like this: // f.h template<typename T> void f(T t) { } // bar.h void bar(); // bar.cpp #include "bar.h" #include "f.h" void bar() { f(42); } // test.cpp extern "C" { extern void __real__Z1fI...

 
2:41 PM
@jalf give jalf amnesia, code works?
 
@CatPlusPlus WTF is that.
 
A week ago, single-sign-on worked sometimes. Now, I can't find a single scenario where it works
 
If you forget about the code, you might accidentally leave it in working condition.
 
sbi
@DeadMG It's the Greek hound of Hades. You've been there? Or is it a relative?
 
Als
@angryInsomniac: Going to quote Meyers, "For Optimization, Profile your application detect bottle necks in the 10% of your code which runs 90% of your application run time and then try to fix that"
 
2:42 PM
woof woof
 
Als
puppy
 
Κέρβερος
 
had it round for Christmas
 
It's Cerberus in English.
 
Kerberos is auth protocol.
 
2:43 PM
fuck me, it's cold in here and I turned the heating on and up high hours ago
 
I'm slow.
 
Als
@CatPlusPlus: You are too late to the party miss.
 
I have two exams tomorrow.
 
Als
@DeadMG: Cold eh...then the first word you said is what you may need :P
 
What are you doing here?
Then you have to stay awake.
 
2:43 PM
Resting.
 
sbi
@RMartinhoFernandes I think the C is Latin. The Greek, as you showed yourself, used K.
 
Als
@RMartinhoFernandes: She is an SO C++ Lounge addict
 
I'll eat something and go to bed now, I think.
Midnight is 8 hours away.
 
@Als If I had an appropriate partner, I wouldn't need low temperatures to encourage me
 
wait... Cat Plus Plus is of the female sort :O
 
2:44 PM
And that'll leave me about 12 hours for learning.
Accounting for slowness.
@thecoshman No, it's just a stupid forced meme nobody else uses.
 
Als
@DeadMG: Pounce the cat puppy! :P
 
Als
lol
 
@CatPlusPlus are not all memes forced?
 
can typetraits be determined by constexpr+overloads?
 
2:46 PM
Hmm?
 
Dogs pounce?
 
instead of template specialization of structs?
 
user406009
I think some typetraits are intrinsics.
 
I thought it was bears.
 
user406009
Like is_pod is definiatly an intrinsic.
 
2:46 PM
No, it's implemented with intrinsics.
There's a difference.
 
Yeah. It's still a struct.
 
@CatPlusPlus when not humping stuff
 
Actually is_pod can be implemented with is_trivial and is_standard_layout.
 
any reason not to use constexpr?
 
user406009
Whatever, __is_pod.
 
user406009
2:47 PM
Close enough.
 
@RMartinhoFernandes which are both implemented with intrinsics
 
user406009
It seems gcc knows they can simplify is_pod

// Could use is_standard_layout && is_trivial instead of the builtin.

from /usr/include/c++/bits/type_traits
 
@rubenvb No idea. I have wrapped all of them in constexpr functions for my own use.
 
@EthanSteinberg I think this is another point for multiline markdown '_'
 
2:49 PM
Well, anyhoo,
0
Q: Why are type_traits implemented with specialized template structs instead of constexpr?

rubenvbThe question is clear. Is there any reason why the standard specifies them as template structs instead of simple boolean constexpr?

@RMartinhoFernandes how do you use the constexpr versions then?
 
Probably because they were shamelessly stolen from Boost.
And that predates constexpr.
 
But constexpr functions can't provide ::type.
 
you could decltype(is_void<int>)
or something
 
Xeo
bool InputManager::is_pressed(Key key, bool once) const
{
    return (_down_cur & key) && once?!(_down_prev & key):true;
}
 
2:52 PM
@rubenvb That's bool()
 
Xeo
can I get that any more obfuscated?
 
I like the "confused operator".
 
@RMartinhoFernandes ah yes
 
Make the manager via static abstract singleton factory.
 
@Xeo sure you can
 
user406009
2:53 PM
At this point I just want compilers such as gcc to blatantly copy boost's threading implementation.
 
Xeo
Hm
 
user406009
It's about time we have good c++11 threading support.
 
Just use Boost.
Or a different language.
 
@EthanSteinberg doesn't GCC already have std::thread?
 
char InputManager::is_pressed(Key key, bool multiple) const
{
    if ((dc & key) && !multiple?!(dp & key):true){
        return 'y';
    }
    return 'n';
}
looks a dam sight worse now if you ask me :D
 
2:54 PM
@thecoshman that should really return a bool
 
@rubenvb obfuscated it :D
you have to wrap the function and check the value your self
 
if ((dc & key) && !multiple?!(dp & key):true){
    return 'a';
}
return 'b';
More obfuscated.
 
@RMartinhoFernandes what's the use of your constexpr type traits?
 
@RMartinhoFernandes well played sir
 
2:56 PM
bool InputManager::is_pressed(Key, bool) const {
    return false;
}
bool InputManager::is_really_pressed(Key, bool) const;
 
WTF's up with "Lightness Races in Orbit"
 
@rubenvb It's purely aesthetic. No ::value's anywhere.
@rubenvb He's Tomalak.
 
thought so. Did he crack his head open even more?
 
I also have template aliases for no typename ... ::type
 
sbi
Great story. (An ad for Canal+.)
 
2:58 PM
It's sweeter to write is_same<decay<T>, decay<U>>() instead of is_same<typename decay<T>::type, typename decay<U>::type>::value
 
true
 
char InputManager::is_used(Key key, bool multiple) const
{
    if ((c & key) && !multiple?!(p & key):(!false)){
        return '<';
    }
    return '>';
}
 
Xeo
@sbi Awesome
 
@sbi Jawesome
 
sbi
:)
 

« first day (458 days earlier)      last day (4491 days later) »