« first day (215 days earlier)      last day (4719 days later) » 

rlc
1:40 AM
good evening
I vaguely remember a way to fill an array of integers, from a typelist, at compile-time, but I can't seem to remember how it was done
anyone here that can jog my memory?
 
I'm not familiar with this. Do you have an example use case (I'm wondering what's the type <-> int relation)?
 
rlc
the type has a value enum that I want to put in the int
it also has a next typedef that points to the next node in the typelist
except for the last node (so I'll need SFINAE to cap it off, probably)
 
If T is a node, is the value accessible from just T::value, or T::value::value?
 
rlc
T::value
and the next value would be T::next::value
oh, and I don't have Boost :-(
 
`template<typename List, typename OutIter>
void fill(OutIter it)
{
*it = List::value
fill<typename List::next>(it + 1);
}`
for the recursive case?
Looks terrible
Can't remember how output iterators work, should be ++it
@RonaldLandheerCieslak C++03? Do you have some type traits?
 
rlc
2:00 AM
@LucDanton C++03, yes
I have the standard library
hmm.. with your suggestion, that would be:
template < unsigned int n >
void fill(unsigned int *a)
{
*a = F_< n >::value;
if (n)
{
fill< n - 1 >(a + 1);
}
}

template <>
void fill<0>(unsigned int *a)
{
*a = 0;
}
 
I'm not sure, what's F_?
 
rlc
T
line before last should read *a = F_<0>::value
not 0 (though it's the same result)
 
And how come it's templated on unsigned int?
 
rlc
that means I don't need to typedef next...
now for the SFINAE bit (for which I will need the next)
 
I wanted to avoid doing that but looks like the simplest way is to write a has_next metafunction
 
2:18 AM
the simplest way would be to write a code generator instead of using templates
 
Not so clear cut if you weigh in maintenance & reuse, no?
 
if you spend as much time on the generator as you guys have already spent here, it should be more maintainable and offer greater reuse :)
 
I don't usually write code this tired though
 
rlc
me too :-)
and the point of the exercise is to explain compile-time recursion to n00bs
SFINAE is just going to be a bit of extra fun
 
tbh I feel I'd be done if this weren't for the requirement that the last node has no next type instead of having a sentinel like void
 
2:26 AM
template<class Node, class T> enable_if<has_next<Node>> fill(T *data) { *data = T::value; fill<Node::next>(data + 1); } template<class Node, class T> disable_if<has_next<Node>> fill(T *data) { *data = T::value; }
@rlc it's not really compile-time recursion, though
@rlc TMP to compute log2 would be a better example of compile-time recursion
 
@FredNurk I'm having fun doing it with C++03 and no enable_if (I haven't written much TMP without the tools tbh)
 
@rlc: or something fun like bitbucket.org/rdpate/kniht/src/e039d5310edd/kniht/…, which lets you write binary<1001>::value or binary<01001>::value and get 9 from both
 
rlc
actually, the compile-time recursion bit is taken care of by generating a Fibonacci sequence at compile-time. The array of integers I want to fill up should contain the Fibonacci sequence at the end
 
fibonacci is also fun stuff to teach with
 
rlc
yes, it is. I usually try to base my stuff for n00bs on real project code (I have a project just for that purpose) but this is a bit outside the scope for that -- and I promised to start talking about template meta-programming a bit
Right, I think that does it :-)
the array contains the Fibonacci sequence in reverse order, but that's not really a problem...
now I just have to write some prose to explain it all :-)
the fun thing with this kind of example is that there's a lot to explain to some-one who's never used templates before
it uses a function template, class templates, and types as well as constants as template parameters
that and compile-time recursion, run-time recursion, SFINAE, ...
gotta go - thx guys :-)
 
3:01 AM
@rlc why stop there when you can use dependent-name nested templates?
(more seriously, teach linear fibonacci generation instead of 2**n)
hmm, I guess Filler<0>::fill should exist but be a no-op
 
@FredNurk It's linear in template instantiations isn't it?
TMP = free memoization by the compiler!
 
that's a good point
there are still far too many people out there that don't realize fibonacci can be linear instead of 2**n, though :(
hmm, and I made that above much more complicated than it needs to be: ideone.com/W9ceA
 
rlc
@FredNurk I want to introduce them to a number of concepts, not blow their brains out ;-)
@FredNurk I tried my hand at Python by implementing a linear Fibonacci - at your suggestion, btw
but I think the 2**n way is easier to explain for now... although your code does seem pretty explainable
 
3:18 AM
def fib(a=1, b=1): while True: yield a; a, b = b, a + b # Python is grand :)
fib20 = itertools.islice(fib(), 20) # btw
I don't see why, in ideone.com/W9ceA, instantiating Fib<1, 1> doesn't instantiate Fib<1, 1>::next, which would lead to infinite recursion
obviously gcc (both ideone and 4.6 locally) can handle it
this line of thinking is why I made next a template, so I could "decide" whether to instantiate it or not
because fibonacci is an infinite sequence, I didn't want the limit to be tied to that class
 
Well
You're thinking of functions
because for a template struct each member is only instantiated on demand, remember?
 
I thought that only applied to methods, not nested types
(which, btw, has hilarious consequences with std::reverse_iterator...)
template std::reverse_iterator<std::list<int>::iterator>; // no way to explicitly instantiate it for non-RA iterators
as explicit instantiation will instantiate every single member
 
You're right ideone.com/Gmgcv
Since you do instantiate a Fib too in your example this is weird
 
even comeau accepts ideone.com/W9ceA in both c++03-strict and 0x modes
 
Also I've used recursely next nested types before
 
rlc
3:29 AM
Filler< Node, 0 > doesn't use Fib at all, no?
 
I've seen it done too in the libstdc++
So there must be more going on
 
@rlc right, filling a size of zero is a no-op
 
Possibly it only for non dependent types that they are declared (i.e. only use them as if incomplete)
 
rlc
so wouldn't Filler<Node, 1> and Filler<Node, 0> both eventually break the loop?
 
then when they are used they have to be complete and they are instantiated
 
rlc
3:30 AM
1> doesn't use next
 
GAH I make no sense at this hour
 
@rlc: I'm thinking in generic code, where size is computed based on something else, you'd want Filler<N,0> to compile
 
rlc
@FredNurk I agree, that's not my point
the reason why your code compiles is because the infinite recursion of template instantiations eventually breaks
 
you're right that my proof-of-concept main doesn't need the 0 base case
@rlc no, it doesn't
oh, it will do something when int overflows
maybe I'm running into hideous implementation-specifics
@rlc I thought you meant Filler would break Fib's loop, but Fib's recursion is independent of Filler
e.g. Fib<1,1>::next::next::next::value
 
rlc
ah, yes
would that work though?
 
3:35 AM
which "that"?
 
@FredNurk I think the minimalist explanation is that for struct { typedef T type; } a;, T is not required to be complete. So in fact there is no need to instantiate the next Fib.
 
rlc
in any case, if we don't know why it works, I don't think I'll let the n00bs figure it out
though I'll save the link as a teaser :-)
 
@LucDanton FDIS 14.7.1p1 lists a bunch of nested things to implicitly instantiate declarations and definitions for upon a class template's implicit instantiation, but I don't see member typedefs included anywhere
 
It's not the same as members though
 
I think p2 says Fib::next isn't even declared until used
 
3:43 AM
But Fib::next must be "valid" in some sense since T* triggers an error when T is U&
Since it doesn't even need to be complete though there is no way a template will be instantiated
 
"The result of an infinite recursion in instantiation is undefined." §14.7.1p15
@LucDanton: ideone.com/5m45F; though better code would be ideone.com/jXp0t
 
Which is equivalent to a snippet where F is only forward declared
That was insightful
 
c++03 and FDIS have no differences in §14.7 that are relevant here, that I see
"instantiating the next typedef member" seems weird, but the catch-all instantiate-when-needed covers it, I guess
and if so, the instantiation isn't required until needed, which means it's not allowed, which means the UB I quoted above doesn't apply
 
4:37 AM
sh scripting, unfortunately, has too many caveats
 
 
2 hours later…
6:34 AM
@FredNurk mmmnot sure, but probably not. Functor has a meaning outside C++ as well. Function object is, as far as I know, C++ only
 
6:46 AM
@FredNurk I'd be careful. The tags are used for all languages and it isn't because a language has then synonymous that they are synonymous for all. (I hadn't see Jalf's answer when I wrote mine.)
 
it's better than the other way around though
 
7:18 AM
Wow, found some real legitimate flags in the moderator tools. I thought those were just a myth.
 
 
2 hours later…
sbi
9:19 AM
@Xeo: I had to delete my comments on your question. That guy is indeed right, clever use templates might let you get rid of having to list all derived classes again. Shall I downvote your answer now? :)
@MartinhoFernandes I tried playing with these tools when I turned 10k, but quickly got bored with them. I guess I'm just not the janitor type.
 
I'd forgotten they existed
 
9:42 AM
@jalf Same for me. They are less intrusive than the notification for the chat rooms.
(I sometimes check the pending edits, but not often).
 
sbi
10:33 AM
That dupe needs two more close votes: stackoverflow.com/questions/6055942/…
 
10:45 AM
@sbi now it's closed :)
 
 
1 hour later…
12:15 PM
hi all
any one can tell me that where is object module for linking the libraries , using VS 2010
hi @als
 
Als
@Miss: Hi
How are you doing?
 
@als: can you tell me that where is object module in VS 2010
fine thanks
 
Als
What are you trying to do?
 
i added some libraies using project properties -> directories ...
now i need to link them..
i know how to link in VS c++ 6.0 ..
but idk in VS 2010
but there is a option for linker in Project properties ...
but i am not sure where is "object module" for linking the libraries
 
what kind of libraries? .lib?
 
12:22 PM
i added some open vs libraries
 
Als
Object module..?
 
open vs libraries?
 
yes
 
you mean visual studio projects from the same solution?
 
yes @als , open or library module
@jalf yes
i found a linker option in project properties ... but i do't know where is the option for linking the libraries
 
Als
12:25 PM
Yes..i guess you should add the lib path there?
 
right click the project -> references -> add new reference
 
Als
Linker options?
 
and select the project there
as long as they're projects within the same solution, VS will handle everything from there
if you need to link to a separate .lib, you need to add it under linker -> input -> additional dependencies
 
ahh yes thats what i want .. thanks to both of you ...:)
ah they are autometically linked
but then why i am getting error.. let me see again
ahh yes i missed one library
thanks you all
 
12:45 PM
hi
Summertime here how should I focus on work?!
:(
 
hehe @nils nice
 
"Let's go bathing after work"
hmmm I hope I get my stuff done today.
 
well i understand the opencv now
but i am still not sure the use of lib's open cv
 
you want to do computer vision?
 
yes
 
12:52 PM
Haven't used opencv, so far just matlab for image processing..
 
hmm i never use matlab
 
computer vision: what exactly?
 
its my first time , work in image processing
 
matlab is easy to play around
we learned it using the Gonzales book
 
but i am looking MFC c++ that work for image processing only
i never see book for that in c++ MFC
 
I'm not familiar with MFC..
@Miss Computer vision is a broad subject what exactly do you want to do?
 
well right now i am doing image processing applications
like moving object detection...
so i am trying to understand that how to load an image from camera
 
so first edge detection and then extract some feature points and track them?
 
yes right
 
12:57 PM
@Miss yeah you don't have this problem using matlab
 
exactly
really
but i think MFc is really good
we can make interactive software...
 
sure
 
but i am not getting the role of the lib that i added from open cv
i need to understand that..
i just added but i do't know its role in my work
 
Personally I would first try out the algorithms in matlab and try to write a prototype. Once it's clear how it works out it would implement it in a "real" programming language such as C++
 
as i think, it is used for loading the image from camera
hmm thats good
right
 
12:59 PM
Aehm..
 
but for me , i think thats my base,,
 
probably also not so difficult with OpenCV
img=cvLoadImage(argv[1]);
@Miss do you have matlab?
 
yes
but i never worked in matlab..:( i want to work in that also ...
 
Well if your not familiar with image processing just I would just recommend to work through the example in the matlab tutorial and maybe use a book like image processing using matlab by Gonzales first.
don't be sad, wouldn't be fun if it were that easy :)
 
i have not image processing book in matlab
but i will check from library ..
 
1:06 PM
good girl :)
 
heheh ... so did you ever use open cv for your work ..
 
no just matlab
 
hmm ..
okz .. well right now i have to understand that how to load an image from camera ... then i will do some small image processing prgrams ....
i need to learn "to load an image from camera " for my project ...
and also movment ...
 
so it can be mounted as an usb storage device I assume
I would just try out the examples from the opencv lib
so will logout now from SO, otherwise I'll never get done anything
good luck
 
heheh right
i should also ...
 
1:26 PM
hi
 
hello
 
not feeling good :cry
 
@DeadMG Sick again?
 
yeah
 
There is no operator; right?
 
rlc
1:36 PM
@MartinhoFernandes that would be fun to have :)
 
Ok, just making sure before fixing the misleading formatting in this answer.
@rlc You could do cool things with it. Like monads.
But yeah, it would be really weird.
 
lol
there is an operator, though
 
rlc
@DeadMG yes, and you can have heaps of fun with that one
 
don't know of anyone, ever, that's done it
 
rlc
1:51 PM
I like the repeat_fun function - it's cheerful :)
 
lol
 
hi all
 
2:06 PM
argh
doing group coursework, and some fuck saved over my work, again
 
sbi
2 days ago, by sbi
@DeadMG See, there is absolutely no, I repeat: NO excuse for not using VCS. Never. NEVER. And that applies to your case, too. (You could have used some VCS just for your stuff.)
The time lost with that easily makes up the time necessary to introduce SCM.
 
you don't know my teammates
 
There is nothing preventing you from starting to use VCS in the middle.
And there is nothing preventing you from using VCS only yourself.
 
we've been working on this project for two months, and they still have to ask me how to add a button to a table cell
 
hg init; hg add *.hpp *.cpp brings such peace of mind
 
2:11 PM
I could use VCS, but quite frankly, I don't know how, and secondly, I really shouldn't have to- backing up the University's servers is the University's problem, and not erasing other people's work is teamwork 101
 
@DeadMG The way I use VCS it's not just about backups
 
@Luc, IMO VCS and backup have different goals. Backup is preventing accidental lost, VCS is keeping history. (And BTW, normally you backup your VCS repositories).
 
@AProgrammer Putting it better than I could :) Pushing the repo offsite brings indeed even more peace of mind
 
i am adding variable control in my Dlg class .. but when i add variable controls in Dlg class, i give me error that "un-able to change the DoDataExchange" function ..
 
2:37 PM
VCS is good for debugging and/or tracing bugs in distributed software. Just because you update it, doesn't mean your clients do, and their specific scenario may be the only evidence a bug exists in the old version (the importance being it may still exist in the new version).
 
@DeadMG offs get rid of your teammates
 
I'm certainly planning on it
 
you'd be better off :)
 
well, this coursework is over in two weeks
hopefully, my intestines will be back to normal in two weeks too
 
now that would be nice :)
 
2:41 PM
or just sometime
yeah
 
what's the coursework about?
 
ASP.NET
webforms
 
oh
do you have to use AJAX too?
 
if necessary, I guess?
but webforms do post-backs to the server of varying descriptons for you, so I haven't found it necessary
 
of course
 
2:45 PM
hi room
@DeadMG which is actually an Ajax call.
 
@Raze AFAIK, postbacks are usually full-page reloads, which is not AJAX. That is, unless you're using UpdatePanels, which are used for AJAX.
 
full page postbacks are not Async and the whole point of AJAX is to have things Asynch, so I agree with @MartinhoFernandes
 
Postbacks are the calls that use the JavaScript __postback right?
 
@Raze Postbacks are just calls to the server with some data or something, usually it is the entire page, like a button click could generate a postback.
 
2:50 PM
@Raze No, postbacks are just a special page reload that sends back a ginormous base-64 string, the infamous "ViewState"
Just look at the source of any ASPX page you loaded on your browser and you'll see the beast.
 
@MartinhoFernandes which where Microsoft stores everything that makes your code behave differently than you expect
In Microsoft's long history of phenomenally bad ideas, the ASP viewstate is a strong contender for the #1 spot
2
 
Yeah, I've been through a lot of these calls that send back viewstate, but all the ones I've checked use __dopostback inside.
 
ok, lets start the ASP.NET rant... :)
I know one worse, VB.NET is actually worse imho
 
@TonyTheTiger ha ha.. I actually haven't worked much in ASP.NET, but we have something similar to a remote browser,
where the browser is in one machine, and it gets particular data from particular site when the user wants it.
 
it's way too verbose, feel like little kid writing code... who the hell writes out the word Function ?!! ugh
 
2:54 PM
@TonyTheTiger I've never really used it, but from what I've seen and heard, it's a pretty solid improvement over its non-.NET ancestors
 
@jalf it is, but I don't like it's verbosity and how you have to spell out everything
 
So I wouldn't consider that a particularly bad idea. They took a broken, crippled language and made it less broken
 
@TonyTheTiger As much as I agree regarding the verbosity, I think it's far from being worse than WebForms.
 
There was some difficulties getting some sites with __dopostback calls working.
 
And apparently you never used VB6.
 
2:55 PM
@MartinhoFernandes only a little of VB6 and I got enough of a taste
 
@MartinhoFernandes I'm happy to say I didn't
 
I've never seen any reason to use VB.
 
So I went through that piece of code very carefully. At first sight, it is a form that submits data back to the server, like a normal, sync call.
 
My top complaint: VB6, AFAIK, holds the record for the highest number of different "null" values packed into a single language.
You thought JavaScript was insane with null and undefined?
 
But a closer look reveals that it doesn't actuall post the form with the VIEWSTATE, but instead puts the VIEWSTATE into an Ajax call and sends it to the server.
 
2:57 PM
VB has Null, Empty, Nothing and Missing.
 
No FileNotFound?
 
All of them incompatible with each other.
 
@Raze yep, the AJAX stuff they managed to graft on top of the webforms/viewstate is another strong contender for the #1 spot
 
@MartinhoFernandes No, JavaScript is NOT insane. Its one of my favourite languages. Its just not primarily an object oriented language.
 
ok, I'm aware of the (huge) drawbacks to the Viewstate and that kind of thing
but it's still way better than PHP's systems
 
2:58 PM
JS has a weak dynamic typing. That's as insane as it gets.
2
 
and also, whilst I think that storing stuff on the server would have been a smarter move, I have to admit, that would take more server power
 
@Raze Well, one of my favorite languages is insane
 
@Raze Having two different null values sounds like schizophrenia to me :P
 
@DeadMG but less bandwidth. Anyway, storing it on the server would be madness too
 

« first day (215 days earlier)      last day (4719 days later) »