« first day (204 days earlier)      last day (4758 days later) » 
00:00 - 14:0014:00 - 00:00

12:23 AM
0
Q: What is decltype(0 + 0)?

Fred Nurk(Prompted by an answer.) Given N3290, §7.1.6.2p4, with the list items unnumbered in the standard, but added for our convenience: The type denoted by decltype(e) is defined as follows: if e is an unparenthesized id-expression or an unparenthesized class member access (5.2.5), decltype...

 
1:07 AM
2
Q: What is a good word for a person who doesn't masturbate?

offengehirnIs there a word for a person who doesn't like to masturbate? If so, what would he/she/it be known as?

4
 
1:26 AM
lol
 
1:52 AM
@FredNurk I don't see how it could be anything other than int..?
 
@RonaldLandheerCieslak: is (0 + 0) an xvalue? why or why not?
 
does it expire?
 
that way of reasoning about *value terms has been outdated since before 1998
A() = 42; // valid given appropriate class A, where A() is an rvalue, where r originally meant "could not be on the LHS of assignment"
 
how is reasoning about an *value in the terms in which it is defined in the standard outdated?
 
xvalue is not defined in terms of "expiring value"
but, even if it was, "expire" isn't in the standard except that place
xvalue is named after "expiring value", but that is all
 
2:07 AM
well, both zeros are prvalues, right?
 
charles touched on that in comments, but he couldn't find anything that said 0 + 0 is also a prvalue
 
well, it's either that, an xvalue or an lvalue. It is not an lvalue (historically, it can't be the left-hand side of an assignment expression). It also does not expire (it is not the result of the "certain kind of expression" mentioned in 8.3.2), so it must be a prvalue
I really don't like the kind of an object being defined the way it is in n3290, however: mostly vague, by example, references historic references that may or may not still apply...
 
I already mentioned "An xvalue is the result of certain kinds of expressions involving rvalue references" in my question (did you read it?), but it's flimsy justification
 
yes, I read it
I'm just going through my reasoning again
basically thinking out loud...
nightcracker IMO has the right answer
1
A: What is decltype(0 + 0)?

nightcrackerYour reasoning is correct. An expression involving only constants is a constant by itself. Thus decltype(0 + 0) x; equals decltype(0) x; which equals int x;

although I'm not sure I agree with "an expression involving only constants is a constant by itself"
that would make a constant out of any constant expression, but doesn't make it a literal
the example in n3290 says that a literal is a prvalue, it doesn't say that about constants per se
 
the type of explanation for xvalue as seen in the note in §5/6 would be nice for an answer
I really don't like how nightcracker's answer relies on intuition for this type of question
 
2:17 AM
I agree
 
@RonaldLandheerCieslak and what is a "constant", anyway? a constexpr? you can get those of any value category with a user function
"literal" is at least unambiguous
though I guess you can have user-defined literals through suffixes...
 
@FredNurk yes, which is the only beef I have with that answer...
 
@RonaldLandheerCieslak well, that's the whole answer... :) and why I didn't upvote it
 
you have a way of being a bit more pedantic than I am
I think the reasoning is OK, though incomplete
the other answer, which says "what would GCC do" is, IMO, far worse
it doesn't answer your question at all
 
I agree, the output doesn't even match the program given, though I didn't bother to point that out
as I didn't want to distract from it being completely irrelevant: gcc gives "i" for int&& too
right now, this appears to be a semantic hole in the draft
and unintentional: "a note in 3.10 indicates that clause 5 should show the category of the value for each built-in operator, the draft doesn't seem to mention a value category for any of the binary operators from 5.6 to 5.15 unless my search powers have failed me." – Charles Bailey
since it can't be fixed, we'll just have to assume the built-in + for integral types yields a prvalue
 
2:26 AM
well, I'm going though n3290 at the moment to find anything that gives an xvalue
if there's nothing there that would point to 0 + 0 rendering an xvalue, it would have to be a prvalue (by process of elimination)
seeing how it's defined, I don't expect a positive response from reading n3290, but I do expect to be able to eliminate others
 
why does the absence of something saying it would be an xvalue then mean it cannot be an xvalue?
why not say the absence of something saying it would be a prvalue then means it cannot be a prvalue?
 
I'm not looking for it saying it is an xvalue: I'm looking for it saying something that points to it being construed as an xvalue
 
what's the difference between "is an xvalue" and "is construed as an xvalue"?
 
if it may be construed as an xvalue, it may still be something else (which would prove the semantic hole)
 
I don't follow
 
2:30 AM
if the standard doesn't say "0 + 0 renders an xvalue" but its wording is sufficiently vague to keep the option open, it may be construed as an xvalue (or a prvalue, for that matter)
 
that last statement agrees with my current thinking, but I don't see how you get from there to "it would have to be a prvalue (by process of elimination)"
 
if I can find language defining what the conditions are for an expression to render an xvalue and that definition excludes 0 + 0, it's a prvalue
but it doesn't seem to be there :-(
OK, I'll try another track of reasoning: 0 + 0 is an expression of which the type must by defined by 5.7...
but 5.7 only defines the resulting type of the expression if one of the two operands is a pointer
still, the built-in operator+ is T operator+(T lhs, T rhs), right?
therefore 0 + 0 renders...
a prvalue (as per 3.10)
now, I just have to check that the built-in operator is T operator+(T, T)
13.6/9
0
A: What is decltype(0 + 0)?

Ronald Landheer-Cieslak0 + 0 is an expression of two prvalues, (n3290 par. 3.10) which applies the built-in operator+, which, per 13.6/9 is T operator+(T), which is therefore a function that returns something that is not a reference. The result of the expression is therefore also a prvalue (as per 3.10). Hence, the re...

@FredNurk I guess there's no semantic hole after all :-)
 
3:11 AM
@RonaldLandheerCieslak: "per 13.6/12 is T operator+(T)" should be "per 13.6/12 is LR operator+(L, R)"
 
@FredNurk thx
I'm reading clause 5 now
but I don't see anything in there that would change the semantics of the built-in operator
the problem is in 5/9, "Many binary operators (...) yield result types in a similar way"
ugh
 
the hole I see is directly caused by 3.10 promising clause 5 will specify something, but that is never fulfilled
this is all based off Charles' comment
I'm not actively looking elsewhere because given the above, it looks like it was just forgotten completely
 
yes, I see your point
 
I still would love a good answer on xvalues, as per my comment on the question :)
 
still 13.6/12 is the only place we have a prototype for the built-in operator
 
3:20 AM
@RonaldLandheerCieslak but what about the "no other purpose" in p1?
 
and as 5 doesn't contradict it either... I guess the "no other purpose" gets shot..
:-|
anyways, I'm getting sleepy - g'night :)
 
'night
thanks for the discussion here :)
 
np. maybe you should drop a line on comp.std.c++
 
I haven't touched usenet in probably 10 years
 
if you have a Google account, you access it through Google Groups
 
3:26 AM
maybe it's time to try it again, we'll see :)
 
 
3 hours later…
sbi
6:37 AM
I keep getting downvotes for this: stackoverflow.com/questions/3329214/…. Am I really off the mark there?
 
6:47 AM
@sbi hi
can you please tell me what's use of '->' in pointers
 
@sbi "I won't even attempt to answer that question" is fairly strong language that might be putting people off, and it sounds like you're refusing to answer
but you only have 3 downvotes compared to 8 upvotes; not yet time to panic
 
@Miss x->y is equivalent to (*x).y.
 
@martinhoFernandes: that mean x pointer multiply by y... no no can you please explain me a little
 
7:11 AM
@martinhofernandes: can you please explain me that a little
 
@Miss: I just don't have the energy to explain it yet again; look up pointers in a good book, especially consider PPPuC
 
morning :)
 
@frednurk ok i have a good book and i did not complete my reading on poitners
so i need to read it after then i talk to you..
 
sbi
7:33 AM
@Miss, are you a Psychology student who's secretly running a test on us for his master thesis on patience? The meaning of -> is among the first things explained in any beginner's book's pointer chapter, and you have been pointed at @Alf's pointer tutorial, which is maybe the most comprehensive one on this planet. Besides, this has been asked on SO and answered, too. If you can't even be bothered to search SO, why should we bother to even look at your questions?!
 
@martinhoFernandes, @frednuk: now i got the use of -> operator
thanks
well @sbi i found it thanks . sorry for disturbing you...
 
Is there a stdlib function to add a sequence to another element-by-element? Like int x[] = {1,2}, y[] = {3,4}; std::foo(x, x+2, y); Now x == {4,6}.
 
@MartinhoFernandes A combination of std::transform & std::inserter (or similar) perhaps?
 
@MartinhoFernandes std::transform(x, x+1, y, x, std::plus<int>); should at least be reasonably close.
 
Sorry about the inserter bit I didn't notice that the result was in place in your example
 
7:45 AM
Oh, I missed that transform overload, and forgot I could just output back to the same sequence. Seems my brain hasn't started yet. Thanks @Jerry.
 
8:31 AM
is this a duplicate? see first and current-last comment
2
Q: Is there a way to compile C++ to C Code?

cl_proggerHi, I have a program which is configured by the user by using C++ classes and the same class should be used to configure a program which can only use a subset of C99 (Open CL Language). So my question is: Is there a way to compile C++ to C-Code? Open Source would be great!

 
@sbi Woot :) You have spoken! :)
 
@tonythetiger: what did he speak ? what woot?
 
8:49 AM
@sbi: hah, you tweeted the english.se link :P
 
9:13 AM
humm I thought that earlier C++ compilers compiled C++ to C
 
Cfront, the first c++ compiler, did, there were a couple derived from it as well iirc
 
9:29 AM
hi all
int main()
{
cout << "Hello world!" << endl;
double* dp = new double[5];// pointer that declare an array
for(int i =0;i<<4;i++)
{
cout<<"elements in array thats pointed by dp are "<<'\n';
cin>>dp[i];
}

_getch();
return 0;
}
is that wrong?
my compiler is not showing me array elements result
why>?
ohh i<<4 my mistake
but compiler did not give me error.. thats strange..?
ah now its working...:)
 
i << 4 is a valid expression
use a std::vector instead of new[]
don't use _getch or system("pause") or anything like that at the end of your program
either setup your editor to run the program in a wrapper which pauses after your program exits
 
Come on brain will u awake this morning?!
 
or run your program from a shell, e.g. run cmd.exe, cd to your directory, run your program, press up to get the previous command back to run again
 
why do't i use _getch()... whats the problem with that..
_getch() is pretty cool...:)
ahh i see
 
Why you don't use cin.get?
 
9:41 AM
well i used that also
i jsut uncommnent that..
 
@Robik don't use that either, for this purpose
 
is this wrong: for(int i =0;i<5;++i)
{
//cin>>dp[i];
cout<<dp[i] =i<<endl;
}
it should run but it gives error ..:(
ahh i guess i found my mistake
 
:)
 
no no sorry
i did not understand mistake..
 
why the assignment in the second last line?
 
cpx
9:51 AM
@Miss you forgot to dereference your pointer.
 
ahh yes
@nils, i just want to print array's indexs hehe
@cpx thanks
 
@Miss Then you need to write: cout << dp[i] << " = " << i << endl;
 
hmm
ah yes @nils right
 
printf("[%d] = %f\n", i, dp[i]);
 
I prefer printf too over cout, it's shorter
 
9:56 AM
Hello world!
ip thats pointed to 10
Array index are :
-4.8367e-026 = 0
-4.8367e-026 = 1
-4.8367e-026 = 2
-4.8367e-026 = 3
-4.8367e-026 = 4
 
@Miss: you have not initialized the data in the array
 
so i get indexs w.r.t its address..
@frednurk: yes i know
 
so I need to focus on work
 
Hello world!
ip thats pointed to 10
Array elements with index are :
[] = 0 223
[] = 1 21
[] = 2 21
[] = 3 12
[] = 4 21
@nils: am i disturbing you?
now its good improvement:
Hello world!
ip thats pointed to 10
Array elements with index are :
0 26
1 215
2 2122
3 21
4 21
 
10:57 AM
my answer there works, but I still find it somewhat unsatisfactory
 
@FredNurk Do you think there's another way?
 
@Miss no it's ok I might just not respond
@FredNurk it's down since over a year or so..
 
@LucDanton: I don't know for sure
 
just use twitter for blogging twitter.com/#!/NightLifeLover
 
@Nils: you mentioned work, so I wondered what your bio said, and saw it. wanted to make sure you knew
 
11:08 AM
@FredNurk I believe the --export-dynamic option covers what is asked in the question
for the ld linker
 
well I'm still a CS student so far but will be done soon
 
Also a linker script can do the same as --export-dynamic but more finely-grained
 
I know very little about linker internals, trying to learn, but little need for more than the basics I do know
 
@FredNurk In your makefile (if you still have it) you can pass -Wl,--export-dynamic for building libx.so and try only linking libx.so from the final executable to see if what I said makes sense
Oh alright I'll mock up a little example of my own then
I admit it's not in my comfort zone either but I remember doing something like this once
 
@LucDanton please feel free to answer the original question instead of fix my example, if that would be better :)
 
11:13 AM
@FredNurk No promises since I usually stick to the common use case as in your example
 
@FredNurk What is $ORIGIN?
 
the location of the executable
itee.uq.edu.au/~daniel/using_origin: "Common use of the -rpath option is to specify fixed library search directories using a PREFIX. However, you may also specify the $ORIGIN token to represent the location of the executable at runtime. Using this technique, you can easily produce binary software packages that are completely relocatable."
the OP's use of -Wl-rpath=libraryX means libraryX in the current directory when executing the program, which could be anything
 
Does this mean it's possible to use -rpath in a safeish manner?
 
I never knew it was unsafe
it does mean you can use libraries that don't have to be installed system-wide and can be kept relative to the executable
without having to ./configure, compile, and install in a fixed location per system
 
Is -rpath=. not relative?
 
11:57 AM
it is relative, but not to the executable's location
 
Relative to the execution dir as opposed to the executable dir correct?
 
it's relative to the current directory
 
Right I got it
 
What happens if your function declaration in the header file has one argument more than the actual implementation? It does not complain when compiling, but gives you a linker error.
Maybe it's time to try out google go
 
@Nils Are you including the header in the implementation file?
 
11:59 AM
guess so
 
@Nils C kinda sorta allows that, C++ doesn't
 
yes
ah well it's compiled with nvcc
so I don't really know weather it's C or C++
 
in C++, you can include the header and not get a problem compiling because your later definition is actually an overload
in C, including the header will (correctly) point out that you've declared the same function with different parameter lists
 
This will happen for freestanding functions but not for members though
 
ok
 
12:01 PM
however, C doesn't use name mangling for linking as C++ does, and C implementations usually allow you to ignore extra (invalid) arguments, per C calling conventions
@Nils: you should include your twitter account in your SO profile
 
@sure
@FredNurk are u on twitter?
 
I can't come to call myself a "twit" yet
 
Hi!
 
cpx
hi
 
@Nils people are starting to collate and use that info, is why I suggest it: brianbondy.com/stackexchange
 
12:06 PM
Hi @Sword22
 
I have this algorithmic homework and I'd like to know your opinion on something, I have a graph represented by a adjacent table and I have to find all the edges that are at a maximal distance of r from a given edge.
For this I think I'll go with Floyd-Warshall algorithm but isn't it like killing a chick with a bazooka?
 
you could just BFS walk the graph maintaining a set of visited nodes, stop once distance exceeds r
 
@FredNurk BFS?
 
FW would work fine, and probably be good experience writing
breadth-first-search
 
@FredNurk like Depth First Search but a bit different right?
 
12:10 PM
en.wikipedia.org/wiki/Dijkstra%27s_algorithm would be better for a single given edge
In graph theory, breadth-first search (BFS) is a graph search algorithm that begins at the root node and explores all the neighboring nodes. Then for each of those nearest nodes, it explores their unexplored neighbor nodes, and so on, until it finds the goal. How it works BFS is an uninformed search method that aims to expand and examine all nodes of a graph or combination of sequences by systematically searching through every solution. In other words, it exhaustively searches the entire graph or sequence without considering the goal until it finds it. It does not use a heuristic a...
 
@FredNurk (Yeah but FW looks simpler to implement)
Thanks
 
dijkstra's is handy to know, if it's all you need (no need to rerun for different starting edges), I'd use it
 
In fact I tried to to that with Depth First Search, but I had trouble figuring how to keep a trace of actual distance
 
for a school assignment, simple recursion (storing 'current' distance as a function parameter) would work
if you want an iterative solution, you need to store your state in a container instead, such as a vector<pair<Node*,int>>, where the int is the distance
 
I guess I'll go with the first option, I think I get it
thanks (: (now to implement!)
 
12:44 PM
@FredNurk I've been ruminating on -rpath and -rpath-link since your last edit
I don't think your example works if libx links to the other libs using -l and -L options instead of passing the libs directly
I think the proper options to pass in that case would be -Wl,-rpath-link=x/y:x/z to find liby and libz
Ack no that fails too, still needs an rpath
At this point I don't think there's a proper answer other than RTFM for ld and particularly regarding -rpath and -rpath-link
 
yeah, I just found a problem too: I'm not using -l so $ORIGIN is ignored
should've added (cd x; ../main) to the test rule in the makefile to test for that
if it wasn't for the desired nesting in the question, I think this would be much easier
I'd have gone with -l, which is what I'm more familiar with, and not missed this :(
 
Does anybody here use gdb with c++ and stl?
 
@Nils I do
 
how do you print like a list?
 
uh
 
12:58 PM
@Nils rarely myself; there are several scripts that aim to make that easier
 
I tried the stl-views from yolinux, but it doesn't work
 
@Nils As Fred said if you have the pretty printers nothing special to do
 
for(list<T>::iterator i = list.begin(); i != list.end(); list++) {
    std::cout << *i << std::endl;
}
 
@DeadMG I wouldn't do that while debugging
 
copy(list.begin(), list.end(), ostream_iterator<T>(cout, "\n"));
 
12:59 PM
sure, but I don't want to have to do that
Why can't they just include stl support in gdb?
I mean stl support which works
 
@Nils it's not a simple problem
 
@Nils what does print p where p is a list
 
yeah but I think it works on Winows
 
it does work on Windows
the Visual Studio debugger has excellent support for data structures
 
yes that's what I mean
 
1:01 PM
so does gdb, but gdb looks at them as C structures, at least natively
 
GDB had scripts for that, AFAIR.
 
and has had scripts for quite a long time now
@Nils: don't forget to try something like ddd or kgdb
 
nah I hate that
it's probably because Linus thinks C++ sucks anyway
 
what makes you think linus has any control over gdb
 
he's not the only one with that attitude
let's face it, Linux is hardly a C++ friendly environment
 
1:06 PM
sure but I'll have to live with it for now
 
the kernel isn't, but I don't see that elsewhere
@Nils: did you try "print p" as Luc suggested?
 
p l
$1 = std::list = {
[0] = 42,
[1] = 69,
[2] = 144
}
works fine with me
 
@DeadMG I thought you avoiding using linux at every opportunity; that's not the best experience to make that judgement :)
 
it's a list of vectors
 
p l
$1 = std::list = {
[0] = std::vector of length 2, capacity 2 = {"Hello", "from gdb"},
[1] = std::vector of length 1, capacity 1 = {"Nils"}
}
What's funny is that I usually debug from crud upon pile of crud because I use a gcc snapshot and the pretty printers aren't usually in sync with the dev
I guess the containers are stable though
 
1:12 PM
@FredNurk: You don't have to use Linux to notice that everyone who does seems to have a hardcore attitude towards C over C++
 
there are more c# apps shipped with ubuntu than windows 7; I have no idea where you're perceiving a C dominance
I suspect c++ is vastly more popular than c on ubuntu's packages too, but I read the earlier statement recently
 
@FredNurk I can't seem to find a 'nice' solution to the -rpath and -rpath-link mess; rpath for the lib seems to 'contaminate' the final executable so you have to -rpath it too while rpath-link seems useless unless it's applied to the final executable
 
even though I don't use it myself, KDE is very popular and very C++-oriented
 
firstly, ubuntu != linux, and secondly, apps shipped with the OS cannot be representative of the majority of programs
or rather, they could be, but there's no reason to assume that they are
 
@LucDanton: -rpath-link is just like -rpath, except doesn't get stored in the executable
 
1:15 PM
@LucDanton hm.. gdb doesn't prettyprint here. Did you add a .gdbinit yourself?
 
@evnu Yes
@FredNurk Well that explains everything
 
@DeadMG I never said all of linux is ubuntu
 
I only ever said "Linux" in general, so the idea of one distro being different is hardly countering my suggestion
 
sure, if you couch all of your accusations in the abstract, it's real hard to counter them, isn't it?
 
not to forget about gcc's C++ error messages
 
1:18 PM
@Nils Could I see examples of MSVC errors ?
 
it's pretty impossible to counter a suggestion which starts with the fact that it's my observation
 
@Nils only comeau, and increasingly clang, have good c++ error messages
 
it's hardly an accusation
 
@LucDanton Sry have to use Linux here..
 
@Nils Nevermind
 
1:20 PM
@DeadMG "let's face it..." "you don't have to use..." imply more than just your personal observation within your limited sphere
 
@Luc: I've got MSVC- what exact error are you looking for the message from
 
@Nils lumiera.org/documentation/technical/howto/DebugGdbPretty.html is how I set up my pretty printers
@DeadMG Something arcane if possible
 
@FredNurk: No, they just imply that using linux != developing for Linux, and != interacting with developers for Linux
 
@DeadMG After using g++ for so long I can decipher the errors quite well but I don't know what the other compilers propose
 
humm I don't want to install all that python stuff, but it may be an option, thx @LucDanton
 
1:22 PM
@Nils It should be shipped with gcc
@Nils the idea is to point gdb to it
@Nils the python stuff is how the libstdc++ team makes sure gdb know what to display
 
huh
it keeps compiling invalid code :P
 
@LucDanton thanks for the link
 
#include <map>

struct x {
};

int main() {
    std::map<x, int> xmap;
}
build succeeded!
 
Nothing to see here
 
that's not invalid code
 
1:23 PM
I think you will find that x has no operator< and therefore cannot be a key in the map
 
you never instantiate anything that would cause an error
 
Try xmap.insert(std::make_pair(x(), 42));
 
@LucDanton: Yeah, just added that
@FredNurk: Nice, so we're down to the ad hominems now?
 
@LucDanton but I have to install that python module
I think I'll apply for any position @MSFT when I'm done studying :D
 
@Nils so locate ".py" | grep libstdcxx or equivalent yields nothing on your system?
@DeadMG Thanks for that
 
1:28 PM
is there an Ubuntu package for it?
 
@Nils it should be contained in your gcc package
 
@Nils gcc-snapshot comes with it
 
gcc comes with python stuff?!
which version?
I have 4.4.5
 
@Nils ever since the libstdc++ team started writing the pretty printers I suppose
 
well I guess the Ubuntu retards just managed to not make it work by default
 
1:31 PM
@LucDanton nice, got it working. Thanks.
 
@Nils I'm not sure it still works for me if I remove the .gdbinit and uses the g++ that shipped with the distro
I introduced the .gdbinit to point it specifically at the pretty printers that came with gcc-snapshot
 
yes but there is no libstdcxx for Python
 
@Nils /usr/share/gcc-4.?/python ?
 
~ > ls /usr/share/gcc*
ls: cannot access /usr/share/gcc*: No such file or directory
 
@Nils: what is gcc --version?
 
1:45 PM
gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5)
 
those pretty printers appear to have been added in 4.5
either apt-get install gcc-snapshot or get the gcc repo and you can put their location in .gdbinit
 
yes
 
@Nils, @LucDanton: actually, it looks like you can just take printers.py out and put it somewhere
 
Figured that out, what I had to do:
Install libstdc++6-4.5-dbg
export PYTHONPATH=/usr/share/gcc-4.5/python
 
don't mess with PYTHONPATH, modify sys.path in .gdbinit as Luc's example has
 
1:51 PM
it was empty before
 
@Nils That's okay
@FredNurk printers.py is regularly updated to follow the libstdcxx developement
 
sure, but unless he's also updating libstdc++, he doesn't need to worry about that
I only mention it because the gcc git repo is large and cumbersome
 
I wasn't sure why you highlighted me
 
I thought you might find it helpful to know the single file works in isolation
I suppose asking a developer to install gcc-snapshot isn't unusual anyway
 
I have the gcc that came with the distro, the gcc-snapshot package, and a snapshot from the repo
 
1:57 PM
works now
 
but then again I'm addicted to the c++0x features
 
thx
:)
 
@Nils happy debugging
 
@LucDanton same, I build from the repo
 
00:00 - 14:0014:00 - 00:00

« first day (204 days earlier)      last day (4758 days later) »