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

6:03 AM
@MartinhoFernandes oh! with the exception of the vec operator+(vec a, vec const &b) case, { return a += b; } prevents copy elision in that case, while { a += b; return a; } can be elided
@MartinhoFernandes: stylistically, I've been "merging" c++ and python to a large degree, treating assignment (and augmented assignment with @= operators) as a statement rather than an expression
it has resulted in much clearer code, IMNSHO
 
@FredNurk I'll mark copy elision as something to understand better later.
 
it's supposed to be something you don't have to think about, as in the first code block in my answer, which is why return statements have a special case so "return obj;" can be interpreted as "return std::move(obj);"
 
And I agree it's a good idea to treat assignment as a statement. But sometimes I get carried away by the "you can write that in a single statement" voice inside my head. :)
 
I have a trusty fallback quip that combats that voice in my head:
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian Kernighan
How do we convince people that in programming simplicity and clarity -- in short: what mathematicians call "elegance" -- are not a dispensable luxury, but a crucial matter that decides between success and failure? -- Edsger W. Dijkstra, EWD648
In the interests of clarity, it seemed necessary to constantly remind myself to pay not the slightest attention to the elegance of the presentation; I adhered conscientiously to the rule of the brilliant theoretician, Ludwig Boltzmann, to leave elegance to tailors and shoemakers. -- Albert Einstein
and I see these three also in my quotes db :)
Programs must be written for people to read, and only incidentally for machines to execute. -- Harold Abelson
 
6:18 AM
I used to think you had to be insane to learn C++. It's massively complex. Now, a month after I started learning it, I haven't changed my mind about that. But now I think it's the good kind of insanity.
 
C++ is insane, there is no doubt about it.
4
I don't mind using it (most of the time), but I've been continuously learning it for about 15 years now. it really is a language for experts
The problem with using C++ ... is that there's already a strong tendency in the language to require you to know everything before you can do anything. -- Larry Wall
 
Sometimes I think that's a good thing instead of a problem. It acts as somewhat of a filter for lousy programmers.
The opposite of languages like C# or Java that cater to them.
 
no, the lousy programmers still try to use C++ -- don't you see SO questions? :P
the ivory tower goal is a language that scales from beginner to expert, and python is much closer to that than c++, imho
@AProgrammer: essentially, I think I dislike that hiding because it breaks the liskov substitution principle
 
Well, I only added C++ to my list of interesting tags a couple of days ago...
 
name hiding was added specifically to break the LSP, so that shouldn't be surprising :) even if the main goal was preserving existing behavior in the face of base class changes
 
6:38 AM
@FredNurk It is not the hiding which breaks the LSP, it is the content of the function.
 
btw, missing ) in that dynamic_cast line
both break it, but I'm unsure of the original purpose for the function
rereading it, "does not forget to implement them" is not a reason to add a virtual
 
@FredNurk I'm not sure it has a purpose. I fear it is the result of confusion...
 
if they should not be called from the base class's interface, they should not exist in the base class's interface
 
@FredNurk When people want to shoehorn OOP inheritance into their problem, that is irrelevant.
 
@MartinhoFernandes The filter is the hype surrounding the other languages. When C++ was hyped, it gathered the lousy programmers.
 
6:44 AM
that's worth mentioning to the OP there, too; stackoverflow.com/questions/6004501/…
 
I remember someone (James Kanze?) on clc++m stating that Java did render a service to C++ in that respect.
 
@FredNurk I don't understand why newbies find it difficult to get these tautological rules of the form "if X then X".
 
What if... C++ had a unary operator for std::move? http://bit.ly/ldmTRW #cpp #cplusplus
that's an interesting idea
I should try convore, but with this chat, twitter, irc (on many networks), ... :(
 
hi all
 
What's wrong with std::move? I agree the naming can be confusing ("where is it moving to?" and "it's just a cast!"), but other than that, what's the problem?
Also, if we did that, I'd want one for std::forward as well.
 
6:53 AM
you'd have to ask him
 
Bah, too much hassle. convore does not support OpenID.
Oh, wait he tweeted that...
 
@MartinhoFernandes hmm, I didn't even notice that; I am starting to like openid more and more
 
Unfortunately Facebook came along to compete with it... Why? Why not just become OpenID providers? (Or is that how Facebook login works?)
 
sbi
@FredNurk I saw it, too, and immediately disagreed.
The problem with that idea is that std::move is way to young to know whether it will catch on. (Anyone remember catch clauses?) I wouldn't want a new language feature (and you can't use an existing operator for that) for something which nobody knows whether it will be relevant ten years from now.
 
I think move semantics will be extremely relevant one year from now, much less ten
 
sbi
7:10 AM
@FredNurk I wouldn't predict that, but if you think so, then it really wouldn't make sense to introduce such an operator. std::move() we can always abandone (who's using std::set_terminate() these days?), but an operator we're stuck with, and it will always interfere with other code. (Not to mention the idea of using an angular bracket. As if that token weren't overloaded enough in C++.)
 
I think I'm going to have to join convore to get in on this idea, it's interesting and I see good points on both sides
he did ask if it was evil... (:
 
7:34 AM
Error 1 error C2511: 'int soundData::FeatureVector::count(void)' : overloaded member function not found in 'soundData::FeatureVector' c:\documents and settings\aa\desktop\aa\lectures\voice recog\aaalacture\loading frames\loading frames\sounddata.cpp 67 1 loading frames
is that mean, count() not found in soundData::featureVectors
hoi
Error 1 error C2511: 'int soundData::FeatureVector::count(void)' : overloaded member function not found in 'soundData::FeatureVector' c:\documents and settings\aa\desktop\aa\lectures\voice recog\aaalacture\loading frames\loading frames\sounddata.cpp 67 1 loading frames
is that mean, count() not found in soundData::featureVectors
Error 1 error LNK2019: unresolved external symbol "void __cdecl soundData::laodFromFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class soundData::Frames &,class std::basic_ostream<char,struct std::char_traits<ch
 
Why would GCC compile something like std::forward(x)? Shouldn't it require a type parameter?
 
I'm still too much of an 0x newbie to say :(
where's litb?
 
i do't understand that error
.
where did i make mistake
?
 
7:50 AM
@MartinhoFernandes Seems a bug to me.
 
where did i make msitake..:(
 
@Miss: you might try isolating a test case and posting a question on SO
 
hy really i am not finding my mistake
you postd an error tooo
.
 
It means exactly what it says on the can. It cannot find the soundData::laodFromFile function.
 
7:59 AM
hmm i see
let me see where is the function, that i have declared but not defined
 
@Miss: laod FromFile could be a clue :)
 
yes the error is in loadFromFile but where let ne see
i think that was problem: ostream& log =std::clog
 
this is why I'd find it really hard to be a c++ teacher...
@Miss: post your question on SO, including everything you've told us so far, and I'm sure someone will help you quickly
 
should i post whole code
i mean not as a link
jsut post code
 
post the declaration of your function and the error message; don't use codepad
 
8:07 AM
hmm i see
so that only mean laodfromFile function and its defination..and error message
 
include what you think is the error, what you've tried so far, etc.
 
Don't be vague, be an ace; write a proper test-case!
 
@fredN: i posted,., i hope i will get reply soon
hmm i see
ahh @fredN.. shit i did spell mistake]
 
8:24 AM
23 mins ago, by Fred Nurk
@Miss: laod FromFile could be a clue :)
 
That makes me wonder. Are there any spell-checkers for C++?
 
ahh i was searching inside the funtion
hy dear i solved one problem .. next problem comes after first...
for me.. programing is error sovlving...
 
@MartinhoFernandes Clang does that I believe
 
i think i did not udnerstand the default parmeters
what is the use of this in main:
void min( int argc, char const* const argv[] )
what is the use of arg
according to my understanding i used like this:
void cppMain( int argc, char const* const argv[] )
{
(argc == 1) || throwX( S()
<< "Usage: "
<< argv[0] << " <file1.txt>"
);


soundData::Frames testFrames;


soundData::loadFromFile( argv[0], testFrames );

// doTimeWarping( templateFrames, testFrames );
cout << "Done." << endl;
}
int main (int argc, char* argv[])
{
try
{
cppMain( argc, argv );
return EXIT_SUCCESS;
}
catch( exception const& x )
{
cerr << "!" << x.what() << endl;
}
return EXIT_FAILURE;
}
and loadfunction like this
/*============loading the frames ===============*/
void loadFromFile(
string const& fileName,
Frames& frames,
ostream& log =std::clog
)
{
using std::endl;
using std::ifstream;

string const streamDescription = "text data file " + fileName;

log << "Opening " << streamDescription << " for reading..." << endl;

ifstream stream( fileName.c_str() );
(!stream.fail())
|| throwX( S() << "Error opening " << streamDescription << "." );

loadFrom( stream, frames, streamDescription, log );
i need to redefine the default parameter 3
i think i did not understand ostream or ..
 
8:41 AM
Short, Self Contained, Correct (Compilable), Example. I cannot even see all that code at once in my chat window.
 
ahh
let me post it as a question
 
good idea
 
next error is coming from @Miss .. anyways i have to understand it
@fredN: i jsut edited the first question
 
@Miss ask a new question rather than editing an existing question to include a new question
 
hmm
ok
@fredN: i must have to say that "thanks for guiding me"
 
8:55 AM
Basically, if you need a new answer, post a new question.
1
Q: Compiler for Win32 Programs?

MCCPI'm going to start learning how to program applications for Windows. I'm not sure what compiler I should use. Right now I'm using the Code::Blocks IDE 10.5 and got used to it and would like to stick to it. Is there any reason to pick the GNU GCC compiler or the MSVC++ 2008 compiler when creating...

Can I get some reopen votes on what I think was a question wrongly closed?
 
@MartinhoFernandes just needs one more, now
 
@raze do you think ,"i am from indea" ?
 
Very much.
 
why and how
 
Your language.
 
8:59 AM
hmm ...
am i writting in indian language....?
 
Indian English.
Slang rather.
Did I get that right?
 
ahh hold on.. i am doing work...
may be ...
 
@Miss on a Sunday noon?
 
yes
 
Got a bug or somethin?
 
9:03 AM
Thanks for the reopen votes.
 
yes Bug
 
9:29 AM
hello all
 
yuupi hi
 
WTF? Downvotes on questions don't cost rep to the downvoter?
Since three days ago.
49
Q: Should downvotes on questions be "free"?

Jeff AtwoodAs I'm sure you all know, downvotes "cost" 1 reputation. That is, every time you downvote: -2 to post owner -1 to you This is done to make sure downvotes are cast only when you feel strongly that something is incorrect / wrong / dangerous / of low quality. We've been tweaking a few thing...

 
Woo, you can now trigger rep recalcs manually. Yay, got 15 rep back.
 
9:44 AM
@TonyTheTiger hello
 
 
1 hour later…
11:11 AM
@MartinhoFernandes hmmm interesting
 
11:38 AM
0
A: Overloading on R-value references and code duplication

FredOverflowSince your vec type is "flat" (there is no external data), moving and copying do exactly the same thing. So all your rvalue references and std::moves gain you absoutely nothing in performance. I would get rid of all additional overloads and just write the classic reference-to-const version: vec...

 
in VC2010 C++ express, is there some threading library part of it, or should I get boost thread?
 
@FredOverflow What problems were you talking about when you mentioned the xvalues?
 
@MartinhoFernandes If someone writes auto&& ret = f();
if f() returns an rvalue reference this can fall flat on its head
if the rvalue reference is bound to a temporary that temporary does not get it's lifetime extended
It's the same problem as returning any kind of reference tbh
 
11:55 AM
@FredOverflow I'm sorry, but you're completely off base here
@FredOverflow: it's true that moving and copying are identical for his type, but not moving nor copying is the goal
 
@FredNurk So you have never heard of the "returning rvalue references" controversy?
 
@FredOverflow GCC claims "absolutely nothing" is wrong, btw.
 
I am aware that it has the same problems as returning a normal reference. if you mean some specific event, what?
 
Of course not, breaking idiomatics is not a compiler error.
vec&& x = y + z; will result in a dangling reference if operator+ returns an rvalue reference.
 
yes, it will
Don't Write Idiotic Codeâ„¢
2
 
11:58 AM
And this was considered so problematic by the experts that they wrote a paper about it, let me find it...
 
If a type is move-enabled might as well cheaply create values
 
No wait, I think it was a defect report.
 
@FredOverflow: however, y + z is not an rvalue reference using my answer
both y and z would be lvalues, thus (y + z) returns by value
vec&& x = y + z + w; // this could result in a dangling reference
 
Erm, sorry, yeah.
 
even so, ask yourself why you want x to be an rvalue-ref -- if you don't have a reason, don't do it
and if you're passing this to a function (e.g. f(y + z + w)), then the temporary is alive until after f returns
 
12:01 PM
@FredNurk And the extension of that is to apply that maxim to return types...
 
@LucDanton: I know why my functions return rvalue-refs: they reuse an incoming rvalue
 
Damn, I only found a dead link in my email box :(
 
I know that -- I suppose my real point is 'You ain't gonna need it' and 'premature optimization is evil'
 
oh sure, I use that argument all the time
but the question was "how do I do this", not "do I need this" or "what should I work on to improve the performance of this code"
"So all your rvalue references and std::moves gain you absoutely nothing in performance." is flat out wrong
and the suggested implementation isn't even a good practice
 
I suppose I could make a case to provide the idiomatic operator+ but provides specific overloads of operator+= on a case-by-ase basis...
 
12:04 PM
And where does it say it's premature optimization? (It isn't premature or non-premature, it's experimental code I'm using to learn)
 
Hm, I think the guideline that you should not return rvalue references is discussed shortly in this video about rvalue references, but it has been too long since I last watched it to be 100% certain.
 
@MartinhoFernandes I'm saying that
 
@FredOverflow: you should implement op+ as T op+(T a, T const &b) { a += b; return a; }
 
I mean, the optimization is done already. I'm trying to do the same with less code.
 
@FredNurk Also fine, but probably less memory-efficient (you touch a's elements twice).
 
12:06 PM
@FredOverflow: it's more cache-friendly
 
Better? :)
 
Yeah I think I have my preferred idiom: provide the "dumb" operator+ not using CRTP but using ADL, which perfectly forwards to operator+=
Then each class can provide overloads of operator+= if better performance is needed
 
@LucDanton I would love to see how you propose to do that, because I couldn't come up with it earlier for the answer we're talking about
unless you mean perfectly forwards in terms of std::forward, because I don't think the intention is to allow any type to be added
 
@FredNurk template<typename T> T operator+(T&&, T&&);
 
12:10 PM
@LucDanton And how do you know which one to add to?
 
So you perfectly forward on type, but any kind of reference
 
yeah, that is what you mean
 
Rvalue reference overloads for *this is in the standard (but no compiler does it ATM)
 
@LucDanton Also, this only works if lhs and rhs are of the same value category.
 
Whoops!
Better have some sfinae then
Want an example?
 
12:11 PM
4 overloads vs sfinae
 
Hello people!!
 
seems about the same amount of work either way
the overloads will be clearer
 
Can anyone help me with basic console graphics in C__
*C++
 
std::is_same<typename std::remove_reference<T>::type, typename std::remove_reference<U>::type>::value that hard to grok? (this might not be what is needed though)
 
apparently it is hard to grok, you're not even sure :)
 
12:12 PM
void main(void)
{
HANDLE hOutput = (HANDLE)GetStdHandle( STD_OUTPUT_HANDLE );
// Set the text output position to (5,10)
COORD sPos;
sPos.X = 5;
sPos.Y = 10;
SetConsoleCursorPosition( hOutput, sPos );

// Set the color to bright green
SetConsoleTextAttribute( hOutput,
FOREGROUND_INTENSITY | FOREGROUND_GREEN );

// Write the text
DWORD nWritten;
WriteConsole( hOutput, "This is a test", 14, &nWritten, NULL );

CHAR_INFO buffer[SCREEN_HEIGHT][SCREEN_WIDTH];

COORD dwBufferSize = { SCREEN_WIDTH,SCREEN_HEIGHT };
 
but I think we both feel like we fully understand the 4 overloads version
 
@FredNurk No I know what this is expressing; I'm not sure this is what I want (do I want conversions for instance)
 
In the above code, how am I supposed to create a colored bar at the bottom of the console?? The above code makes the bar at the very top but I wan't to create the bar at the bottom. How am I supposed to do that?
 
@LucDanton: what if T is const and U isn't?
 
@FredNurk Liberally add some remove_const
also you can refactor the whole thing in a helper
 
12:14 PM
@LucDanton: what if T is volatile and U isn't?
 
Als
@FredNurk, @FredOverflow: Both Freds are really overflowing in the starred quotes :P
 
@FredNurk I'm not sure about that; how does your version handle volatile anyway?
there's no const volatile -> const implicit conversion right?
 
@LucDanton makes a copy of the volatile arg
 
Mmh
How is the some_type(some_type const&) call resolved?
const volatile& => const& ?
 
hmm, I guess that's not an identity conversion
was thinking initialization of const& to a temp
 
12:17 PM
Still I don't think my way competes with your Fred tbh
It's what I'd do first; I do see a need for CRTP iff a) performance is needed b) lots of classes to affect
I find a) to be a bit caveat
 
you have a return type problem: return T or U? what if T or U is a reference type? (that was the whole point to avoid in the first place anyway)
 
std::common_type<A, B>::type
Fuck no
just decltype the problem away <- still needs a common type somewhere
 
with remove_const and remove_reference again? :)
 
Probably yes
 
12:20 PM
you can't decltype the problem away: auto op@(T &&a, U &&b) -> decltype(forward<T>(a) @ forward<U>(b)); // recursive return type
 
I edited to point out my mistake
 
still not used to editing chat
 
so I thought that MS VS 2010 would contain at least part of the new C++11 standard and I assumed that std::thread would have already been part of that?
 
TBH for having written some SFINAE stuff I'm in the habit of repeating myself
 
but it seems that #include <thread> it cannot find it
hmmm
any ideas?
 
12:21 PM
hmm, does forward help there?
 
In those cases I refactor the std::remove_reference/const whatever in a helper so no maintenance problem
e.g. I have a is_related<U, V> for perfect forwarding constructors
@FredNurk Yes (ignoring the recursion)
 
std::forward is still mostly an enigma
 
also I mean decltype'ing in terms of op@= (but to copy a you need the std::common_type stuff)
Is it?
std::forward<T>(t) means pass t as you accepted it
 
@TonyTheTiger They are probably waiting with std::thread until MSVC supports variadic templates.
 
12:28 PM
@FredOverflow hmmm ok
so I'll just use boost then
 
Is boost::thread header-only code?
 
@FredOverflow I think so
I can only see headers
 
I just found an interesting paper on the new value terminology.
3
 
@FredOverflow interesting ;)
Welcome @sbi
 
sbi
@TonyTheTiger Hi @Tony.
 
12:37 PM
@sbi hello! How is Sunday?
just installing the latest version of Boost on my home machine
so I can keep playing around with C++
:P
 
sbi
@TonyTheTiger To say it's lousy would be an ephemism.
 
@sbi oh... not so good
35k files in boost lib... damn
 
Can anyone here help me pls with console
??
 
@Spoilt what's the problem?
 
In the following code, how am I supposed to create a colored bar at the bottom of the console?? The following code makes the bar at the very top but I wan't to create the bar at the bottom. How am I supposed to do that?
void main(void)
{
HANDLE hOutput = (HANDLE)GetStdHandle( STD_OUTPUT_HANDLE );
// Set the text output position to (5,10)
COORD sPos;
sPos.X = 5;
sPos.Y = 10;
SetConsoleCursorPosition( hOutput, sPos );

// Set the color to bright green
SetConsoleTextAttribute( hOutput,
FOREGROUND_INTENSITY | FOREGROUND_GREEN );

// Write the text
DWORD nWritten;
WriteConsole( hOutput, "This is a test", 14, &nWritten, NULL );

CHAR_INFO buffer[SCREEN_HEIGHT][SCREEN_WIDTH];

COORD dwBufferSize = { SCREEN_WIDTH,SCREEN_HEIGHT };
 
12:40 PM
Have you posted a question on the main site?
 
Yep
Here:
 
@MartinhoFernandes I think this is indeed a good candidate for an SO question
 
I am not getting the answer that is being posted there
@TonyTheTiger pls help me in this regard
2
Q: Console Graphics Help!!

SpoiltIn the following code, how am I supposed to create a colored bar at the bottom of the console?? The following code makes the bar at the very top but I wan't to create the bar at the bottom. How am I supposed to do that? void main(void) { HANDLE hOutput = (HANDLE)GetStdHandle( STD_OUTPUT_HAND...

 
@FredOverflow bg motivation like that is so rare for c++, yet people seem to ask about it a lot
 
@FredNurk bg motivation?
 
12:43 PM
I am not very well acquainted with the windows.h so i need help..
 
@Spoilt can't help you, haven't got much experience with that
 
@TonyTheTiger K No problem :)
 
@TonyTheTiger bg=background
 
@TonyTheTiger You may find the nuwen MinGW distro interesting. It already includes the latest Boost.
(The current version is 1 month old and it is regularly updated.)
 
@FredNurk After some consideration I think there is more than one way to do what I'm trying to do (which have their own pro's and con's) and it's also completely irrelevant to the situation your answer is applicable to
re: operator@[=] and all that jazz
 
12:55 PM
@MartinhoFernandes can u help me with the problem i just posted on this chat??
 
> This leaves [...] values that have identity and can be moved. We really don't have anything that guides us to a good name for those esoteric beasts. They are important to people working with the (draft) standard text, but are unlikely to become a household name. We didn't find any real constraints on the naming to guide us, so we picked 'x' for the center, the unknown, the strange, the xpert only, or even x-rated.
LOL, so that's what "xvalue" means :)
 
@Spoilt No idea, sorry.
 
@FredOverflow Someone was having fun; who wrote that?
 
Bjarne. Whenever I omit the author, it is usually Bjarne.
 
1:35 PM
@FredOverflow: I still can't justify "never return an rvalue reference", and certainly not based on "T&& x = a + b + c;"; take "T& x = (T() = T());": x is still a dangling reference, but we don't say op= shouldn't return by reference because of that
and after going over your link to Abrahams and Hinnant with some time to think it over, I can't see how they point out a problem except in the "T&& x = a + b + c;" class of case
 
@FredNurk I removed the accepted mark while the discussion goes on.
 
1:58 PM
1
A: Overloading on R-value references and code duplication

FredOverflowSince your vec type is "flat" (there is no external data), moving and copying do exactly the same thing. So all your rvalue references and std::moves gain you absoutely nothing in performance. I would get rid of all additional overloads and just write the classic reference-to-const version: vec...

Look at that, Howard agrees with me :)
 
and yet he can't give any reasons; see the comments on my answer
 

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