« first day (225 days earlier)      last day (4721 days later) » 

12:00 AM
For example, given a Boolean condition and a variable typename T, generate either T or int.
 
ohh
i think that is std::conditional<>
 
Xeo
What are you guys up to and may I join?
 
hm but that will be nondeduced
 
of course, conditional< cond, T, int > won't work because ::type is non-deduced.
@Xeo same thing we do every night… try to take over the template semantics!
3
A better phrasing of the problem is to vary the number of dependent contexts in a single declaration.
 
Xeo
@Potatoswatter Yes, but what exactly? D:
 
12:05 AM
If you can decrease that number by one, then the declaration is more specialized, and gets chosen over the existing overloads.
@Xeo Trying to make template declarations count.
 
Xeo
@Potatoswatter Umm... ?
 
lulz
@Potatoswatter i believe someone from boost helped me create a solution at that time
i forgot where I stored it
something nasty with ...
 
@JohannesSchaublitb I think I had an idea for parameter packs, but I'm trying to do it in C++03.
 
we added function declarations into a namespace, each one having one named parameter more than than the previous, that at that place only had an ellipsis
but unfortunately, in C++03 mode you have to do nasty repetition work
in c++0x it'S more easy I think
 
Yep.
You can use the parameter pack expansion in a friend function.
 
12:08 AM
yeah
decreasing the number by 1 to get a less specialized function for overload resolution is possible
if you have a fixed maximal number you pass as argument
but that requires a maximal number up to which you want to count which is bad :)
 
Aha! Call the overloads with an int ***********… variable, using the compiler's limit of indirection.
 
all these tricks will require knowing the ever-maximal count
 
There's always a maximal number, even the parameter pack size.
Yes, needing to know the maximum is bad.
 
but in the parameter pack size, you don't need to know the number. you can leave it for the compiler to say "stop" at one point
so if you only count up to 10, you don't need to create a pack with 1000 elements.
 
If only there were partial ordering operator that conditionally ignored one type, you could count to 2^n for only n levels of nesting.
 
12:14 AM
so you can create template<int N> struct D : D<N-1> { }; template<> struct D<0> { };. Then you can have void f(D<1>); void f(D<2>); void f(D<3>); and if you call it with f(D<100>());, it will select the D<3> version
but it will have a maximal of 100 functions
it would be best if you could call it with D<0>() and it would somehow choose the D<3> version xD
 
Xeo
@JohannesSchaublitb Have implicit conversion from D<0> to the last know instantiation? Should be somehow possible with some SFINAE trickery, no?
 
@Xeo another victim! LOL
 
Xeo
And now, would you mind explaining me what exactly you're trying to do? I'm bored and I want to write some TMP stuff!
 
ah I think there may be a way
struct end { }; template<int N> struct not_end { }; char (&is_end(end))[1]; template<int N> char (&is_end(not_end<N>))[2]; template<int N> not_end<Z> f(D<Z>, D<N>, bool(*)[sizeof is_end( f(D<N+1>(), D<N+1>()) ) == 1] = 0); end f(...);
Z needs to be incremented each time
 
12:24 AM
I like the derived classes idea… that might get me around the need for a dependent context…
 
Xeo
Guys. Are you trying to count the amount of times a template has been instantiated?
 
@Xeo Pretty much.
 
Xeo
Thanks for a clear answer for once!
 
@Xeo Well… you have one template that returns the number of times another template has been instantiated.
 
12:28 AM
i believe the original goal was to implement enumerations..
 
Xeo
Lol
 
and then the need arose to count how many enumerators there already are ...
 
The latter template will evaluate the first.
@JohannesSchaublitb It does more than enum though, the problem genuinely arises if you want to build a table of included header files, for example.
 
Xeo
@Potatoswatter calling example?
 
@Xeo calling?
 
12:30 AM
ohh!
 
Xeo
@Potatoswatter Example on syntax, how you would call that metafunction
 
@Xeo Depends how it's implemented. We've essentially chosen friend functions to return the count.
e.g. sizeof f()
 
oh NOO my snippet wont work :(
 
Xeo
size_t count = NumberOfInstantiations<MyTempl>() ?
 
12:34 AM
size_t count = sizeof get_counter();
 
my goal was to have a #define INC(name) macro. and if you do INC(foo), it increments the count of foo
and later with VALUE(foo) you get a compile time constant for the value of foo
 
Xeo
@Potatoswatter wait, I thought you can't overload on the return type?
 
only templates can be overloaded on return type
 
@Xeo You can't. The function needs to be called the same way each time, yet you automatically generate a better-matching overload with every increment.
 
Xeo
@Potatoswatter Ahh, I see what you're trying to do now
 
12:40 AM
my strategy has been to try to cause deduction failure for all but the last declaration. but it's not easy I think
 
Xeo
@JohannesSchaublitb Yeah, that's my idea too now.
 
@JohannesSchaublitb Yeah, I think that leads to a conundrum because you need another declaration that triggers SFINAE in the chain. Now you've pushed the problem somewhere else.
 
Xeo
template<int N>
struct D{
  D(D<0> const&, SFINAE_IF_LAST_INSTANCE){}
};
Now that SFINAE part is going to be tricky
Okay guys, now you got me hooked for this one :P I'm in.
 
Xeo
I love interesting problems, and this one definitly does count
Hmm.. you could also get away if you could conditionally make an explicit specialization on the last instantiation only and nothing else.
Though I can't imagine a syntax for a changing full specialization
 
12:49 AM
@Xeo That's what's nice about friend functions. They're like explicit specializations, but aren't templates.
TMP is a functional language and friend functions are side effects. You would hope that would enable counting.
 
Xeo
@Potatoswatter Mind an example on the overloading of friend functions?
 
i thought that this should work:
but crashes compiler :( (including clang)
 
@JohannesSchaublitb You still get bonus points though.
 
Man, you need to insert more line breaks.
 
Xeo
Seriously, I'm trying do dechiffre it right now..
 
1:08 AM
i don't know whether the code is correct
couldn't test it :(
 
Xeo
@Potatoswatter How does template class s< 4 >; work without template<> ?
 
@Xeo It's not declaring a specialization, it's explicit instantiation.
 
Xeo
Oh!
 
s< 4 > dummy; would also work, but this is more specific.
 
Xeo
Good to know about explicit instantiation...
 
1:11 AM
@JohannesSchaublitb I think you might be running into a bug I filed a while ago.
Put that in your other compilers and smoke it ;v)
 
ah looks like a stack overflow inside GDB
goes like that all the way down: codepad.org/DRLtUslL
s,GDB,GCC,
oh noo i see now what happens xD
sfinae recursion -.-
 
"point of instantiation" ugliness?
 
the template just accepted the call itself -.-
 
Xeo
1:35 AM
aarrrrgh
y u no do what you should :(
Argh... I'm stupid. -.-"
 
1:53 AM
Hey, I think I'm on to something… chain several functions together so the query looks like sizeof f(g(h)). Then you can have 2^n possible results for n levels of function-call nesting. Maybe.
But, I'm off to dinner for a bit.
 
Xeo
Eh.. my counting method works for explicit instantiations but not for dummy variables created...
 
That's fine. Explicit instantiations are cleaner. How high does it count?
 
Xeo
depends on the number of instantiations. :P
and syntax is always D<0>::_count
but I found a problem that makes the whole attempt void.
It's not a constant integral expression T_T
 
So… a text file with a million explicit instantiations would result in a count of a million? That would be awesome.
 
Xeo
@Potatoswatter I think the limit is 500 on MSVC, template recursion depths
 
1:56 AM
Then that's another limit ;v)
 
Xeo
Well, try and beat the template recursion depth. :P
but nevermind that idea because it's not an ICE
Meh. Why can't we have the preprocessor and templates interact? :|
 
Xeo
2:11 AM
Wtf
Why are we allowed to overload on different return types with variadic parameters?
struct Yes{ char dummy; };
struct No{ Yes dummy[2]; };

No check(...);
Yes check(D<0> const&);
No complaint (global namespace)
 
rlc
2:31 AM
@Xeo why shouldn't we be allowed?
 
Xeo
I think I need to get some sleep, see ya later
@rlc Heh, good call. The number of parameters is different after all, so yeah, I definitly need to get some sleep
 
rlc
g'night :-)
 
 
3 hours later…
5:09 AM
Only function call "nesting" used, which isn't really nesting. Highest count value is 2^n with nesting degree.
 
5:54 AM
hi @potatoswatter
@nils hi
 
6:29 AM
@als hi
@als i need a little help .. can you please guide me a little ... i am stucked due to one problem..
Anyone here ..?
 
Als
6:46 AM
@Miss: hello
 
ahh thanks hi
 
Als
sorry didnt see your messages at me before
 
hmm ok its ok ...
 
Als
What problem? I can try
 
but i need your favour ...
ok see i am making project for loading a picture from a webcam.
 
Als
6:50 AM
@Miss: I don't know if i have the competency in the problem u have or the area you work in, but quote your problem in simple easy to understand words and i can try to help you.
 
and I am getting an silly error that me and my friend did not understand the reason for that error .. according to the definatiion of AfxMessgeBox() ==> http://msdn.microsoft.com/en-us/library/as6se7cb(v=vs.80).aspx

my program should work.. but i am getting error in AfxMessgaeBox() statement ./.
program statement is :

int nSelected = cvcamGetCamerasCount();
if(nSelected == 0)
{
AfxMessageBox("Camera have no connection",MB_OK|MB_ICONSTOP);
return FALSE;
}
error :
Error 2 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types c:\program files\microsoft visual studio 10.0\my project\objectbounddetect\objectbounddetect\objectbounddetectdlg.cpp 126 1 ObjectBoundDetect
yes i am trying my best to quote my problem in simple way,...
it should work according to the defination given in the above link ... but why do't work .. i think i passed right parameters..
 
Als
AfxMessageBox(nStringID, MB_YESNO|MB_ICONSTOP);
 
yes
 
Als
NOTE: nStringID is an integer that contains a valid id of a string in the current resource.
I think it should work though
 
yes
 
Als
6:55 AM
what is line 126 in objectbounddetectdlg.cpp?
 
line 126: AfxMessageBox("Camera have no connection",MB_OK|MB_ICONSTOP);
 
Als
A min pls
I will be back
 
hmm ok i will wait.. please help me in this regard ..
thanks
 
Als
Try this...
AfxMessageBox(_T("Camera have no connection"),MB_OK|MB_ICONSTOP);
It should work now.
And now you should tell me why it didn't work in your code.
 
yes that error removed .. now i have linker errors.. i have to do work further..
thanks
 
Als
7:01 AM
Well, you still have to tell me why it didnt work for you
 
but why did you put _T in front of the strings
 
Als
and why it worked with that modification
Important part is to not just get rid of the error but to understand why the error and How it was solved so you can avoid it next time.
 
yes i am thinking that why its solved
whats in _T
let me see defination again
and then think again
 
Als
Okay, i tell you but you should learn this in books before you actually program.
You are compiling ror the unicode character set, but feeding the functions with multibyte string literals.
 
hm
 
Als
7:05 AM
If you want to compile your application for unicode, you should either prefix your string literals with L, to indicate that it is a wide character string, or surround it with _T("mystring"). The latter is a macro, which expands to the L prefix when you're using unicode, and plain string literals otherwise.
 
ah i see ..
 
Als
If you did not understand the things i said, you should search for each of them in your book or google and learn more about them
 
yes i am doing it ..
 
Als
Good..Okay then have a good day..gotto go
 
hmm ok @als thanks ... i will do my best .. take care ,.. bye bye
 
7:11 AM
0
Q: Can C++03 template declarations number themselves sequentially?

PotatoswatterFor the purpose of introspection, sometimes I've wanted to automatically assign serial numbers to types, or something similar. Unfortunately, template metaprogramming is essentially a functional language, and as such lacks global variables or modifiable state which would implement such a counter...

@JohannesSchaublitb @Xeo - Solved it!
 
7:34 AM
morning all
 
@TonyTheTiger gummorgning
 
8:08 AM
gunnite!
 
8:49 AM
hi
 
I know now why my code didn't work. because it required that foo<X> when instantiated one time works different than instantiated another time (when a greater foo was declared).
@Potatoswatter nice bitfield code
on a standard conforming compiler, sizeof check( query ); must instantiate the template and yield sizeof(int) even in the first case though :)
@Potatoswatter in fact, GCC4.6 on my system outputs "4 4" for your true/false example :)
 
9:09 AM
@Johannes Is (a = b) = k well-defined in C++0x? See my comment here:
1
Q: Is the expression (a=b) = k UB?

Pavan WLAIs (a = b ) = k undefined behavior if a,b and k are of int type and properly initialised? thanks

 
@Potatoswatter hmm so I suspect your bitcode example too will always yield 2^13-1 :(
because it calls seen with the pointers which will instantiate the template and declare the friend function :(
@FredOverflow i sent a nerdy answer to usenet for that question xD
 
Why didn't you post it on SO?
 
I had no idea it was posted on SO too
lulz
 
Well, now you know. copy/paste to the rescue?
 
dammit why does arcor print "Organization: Arcor" after all my usenet answers!
fuck that -.-
i just wanna have a free usenet access :P
 
9:15 AM
First I read "all my useless answers", lol :)
 
Well, it seems you're working for Arcor now? :)
 
everyone of the other 4 answers say "it's not UB perfectly fine". i'm the only one so far claiming it'S UB
haha
no but i'm using their usenet access
i don't know of other free usenet accesses
 
Can you post a link?
 
9:20 AM
a = b = 2 could in theory first write the 2 to a and then to b, right?
 
that's explicitly ruled out
 
Really? Why?
 
ah wait, I don't know exactly, but I believe it can
the spec says " The result of the
assignment operation is the value stored in the left operand after the assignment has taken place; the result
is an lvalue."
so the value that "a = b ..." reads from is the new value of b
which seems to indicate to me that first b needs to be assigned before a can be assigned
still they happen in between the same sequence points
so basically there is an ordering for the assignments, also in "(a = b) = c", but nevertheless behavior is undefined because there is no sequence point in between them
In C++0x this weirdness is fixed though and behavior is well defined, IIRC
 
@JohannesSchaublitb That's exactly what I wanted to hear from you :)
 
9:30 AM
12 hours ago, by Tony The Tiger
he's here only so often and mainly says 'hmm' and 'lol'
 
i will change to lulz now
 
do ppl automatically get removed from the room owner list if they don't frequent the room often?
 
9:32 AM
5
A: Does C++ support compile-time counters?

PotatoswatterClass templates can declare friend functions, which have access to template parameterization without being templates themselves. When a template is instantiated, its friends are effectively declared and added to the local namespace. The namespace can therefore be used to store global state. Func...

Wow, does that really work? Cool.
 
@FredOverflow doesn't work I think
see my comments above
43 mins ago, by Johannes Schaub - litb
I know now why my code didn't work. because it required that foo<X> when instantiated one time works different than instantiated another time (when a greater foo was declared).
that one and following ones :)
 
(that particular message doesn't refer to that code, but the following ones do :))
 
Ah, so it's like a sentinel message before the first real one :)
 
9:36 AM
Boy I'm rusty on x86 asm... does mov eax, var mean load the address or the value of var into eax?
 
Xeo
@FredOverflow should be value
lea eax, var should load the address ... "load effective address"
 
no
lea assumes you start with the address
it's for things like array/struct address computation
 
I think mov eax, var loads the address and mov eax, [var] loads the value...?
 
of course, the address should probably be on the stack or pointed to by something, so it's not that hard to find
 
Does lea eax, var even compile? Shouldn't it be lea eax, [var]?
 
9:39 AM
@Potatoswatter and I get the error from GCC4.6:
main1.cpp:55:1: error: duplicate explicit instantiation of ‘struct memo<8192u, 0u>’ [-fpermissive]
main1.cpp:56:1: error: duplicate explicit instantiation of ‘struct memo<8192u, 0u>’ [-fpermissive]
main1.cpp:57:1: error: duplicate explicit instantiation of ‘struct memo<8192u, 0u>’ [-fpermissive]
main1.cpp:58:1: error: duplicate explicit instantiation of ‘struct memo<8192u, 0u>’ [-fpermissive]
:(
 
Xeo
It seems I'm rusty too with x86 asm
 
@JohannesSchaublitb Have you tried the -gentleman option for GCC to treat you nicer?
 
sbi
@JohannesSchaublitb open-news-network.org
 
9:44 AM
ohh thanks!
it says "temporarily suspended due to unresolved legal issues" -.-
 
sbi
@JohannesSchaublitb Durn, I didn't know that! I'm using Usenet through them. No I wonder.
 
sbi
@JohannesSchaublitb Where does it say that? I can't find it.
 
sbi
@JohannesSchaublitb Well, I haven't seen that on open-news-network.org/index.php/Nutzungsbedingungen, so I suppose it has something to do with international users? Why don't you just try registering?
 
9:53 AM
ohh
BTW I found really interesting things last week...
class X will not ignore class templates called X
so in fact, when the spec says "ignore non-type names", it actually means "ignore non-{type, type-template} names"!
 
Xeo
Huh? Example?
 
so it will not ignore class templates
 
10:27 AM
@JohannesSchaublitb : did you see my edit?
 
10:39 AM
@FredOverflow IIRC, it depends on the assembler variant you are using. There isn't only the ATT/Intel syntax dichotomy, assemblers using Intel syntax varied also on such thing. Still from memory, MASM behavior in this case will depend on the way var has been defined...
 
sbi
@JohannesSchaublitb It seems we're using quite incompatible definitions of very interesting. :-x
 
11:10 AM
I'm cheating on C++ again...
0
Q: Does volatile influence non-volatile variables?

FredOverflowOkay, suppose I have a bunch of variables, one of them declared volatile: int a; int b; int c; volatile int v; If one thread writes to all four variables (writing to v last), and another thread reads from all four variables (reading from v first), does that second thread see the values written...

 
11:21 AM
@Johannes @sbi Should we remove our C++0x comment noise on the question? :)
 
sbi
@FredOverflow Done.
 
@sbi Done.
 
@FredOverflow done
should SO support brace expansion in @-addresses? @{FredOverflow,sbi} ?
 
@JohannesSchaublitb Can user names include braces?
 
not sure
0
Q: Simulating finally block in C++0x

NawazInspired from the other topic, I wrote this code which simulates a finally block: #include <cassert> #include <iostream> struct base { virtual ~base(){} }; template<typename TLambda> struct exec : base { TLambda lambda; exec(TLambda l) : lambda(l){} ~exec() { lambda...

 
11:37 AM
Why would we even want a finally construct in C++ if we already have RAII?
 
@JohannesSchaublitb: I'm waiting for you :D
 
looks like it's already solved
 
11:55 AM
@JohannesSchaublitb: yeah... btw I was trying to use reference instead of pointer, it didn't work.
is there any chance of improvement?
the current impl is this : ideone.com/hsX0X
 
@Nawaz I'm writing a demonstration of the ScopeGuard trick but with C++0x features for you
 
@LucDanton: hehe.. good.. just show me once you're done.
 
If you really want to use auto then you have to use a flag inside the class
Since you have to return by value from finally and you only want the functor to be run once
The advantages of a flag is that you can provide a cancel operation, too
 
Xeo
12:29 PM
@JohannesSchaublitb Isn't that just RAII with an executed lambda in the destructor?
 
12:40 PM
For the German speaking an interesting article about a project at the EPLF to reverse-engineer the human brain nzz.ch/nachrichten/startseite/…
hello btw :)
 
Xeo
@Nawaz: What's wrong with something like this, without any heap allocation? ideone.com/Q55us
// gcc-4.5 can't handle default here
final_base(final_base&&) {} // = defaut;
Maybe it can't handle "default" because you wrote "defaut" (missing L) ? :)
Hm, interesting. Wanted to repin the newbie hints message from @sbi, but the chat tells me the following: "You have starred and pinned this message.". I don't remember pinning it yet oO
 
12:58 PM
Which document is the newest c++ standard? I have n3290.pdf is that the newest?
 
Yes.
 
Somehow I can't find it on open-std.org
 
en.wikipedia.org/wiki/C%2B%2B0x says it's a dead link, interesting...
 

« first day (225 days earlier)      last day (4721 days later) »