« first day (605 days earlier)      last day (4326 days later) » 

Ell
 
@FredOverflow Will it work in a struct as well?
 
@ManofOneWay Sure, why not? Classes and structs are almost exactly the same thing.
 
That's what I thought =)
Thanks
 
@ManofOneWay of course. A struct makes things public by default, but otherwise is the same as class.
 
@JerryCoffin You thought of everything ;)
 
7:01 PM
@FredOverflow Not at all -- that's included in "thing" -- exactly why I didn't say "members"
 
nevermind
 
@FredOverflow prepare to run spellcheck
 
@sehe Isn't that supposed to start with something about "your mission, should you choose to accept it..."?
 
7:02 PM
@JerryCoffin No; I don't do cultural references
 
Do you, at least, get this one?
This one you must get.
 
Only slightly annoying, that
 
@sehe Wow -- that qualifies as "culture"?
 
@JerryCoffin Anything that can count as an excuse, yes
 
@sehe Ah hah!
 
7:04 PM
I do 'recognize' stuff like that. But firstly: I don't do television. Secondly: I don't the remembering thing.
On the bright side, I don't do highly exposed hull breaches
Good morning to you to, indiscrete genius :)
 
@DiscreteGenius -> ideone.com
 
Good morning ladies and gents. Sorry for that nasty paste job
 
@DiscreteGenius Dude, post that to ideone, quick before it gets binned :)
 
@DiscreteGenius What are you asking about -- just using declarations vs. using directives? If so, I'd say the using declarations are generally preferred.
 
7:08 PM
96
Q: Why is 'using namespace std;' considered a bad practice in C++?

ManaOkay, sorry for the simplistic question, but this has been bugging me ever since I finished high school C++ last year. I've been told by others on numerous occasions that my teacher was wrong in saying that we should have using namespace std; in our programs, and that std::cout and std::cin are m...

 
@JerryCoffin That one is struggling, eh?
 
@RMartinhoFernandes Never!
 
@JerryCoffin I understand reasons for not using using namespace std; but my main concern what the way of going about the idea: Reading some text into a vector, storing each word in the input as an element in the vector, then transforming each word into uppercase letters. Then, printing the transformed elements from the vector, print only eight words to a line.
 
I suddenly realized that "kidnapping" means "kid napping".
 
That's when a kid takes a nap, right?
 
7:11 PM
:D
 
@FredOverflow That's correct.
 
Sure..
 
@DiscreteGenius So what is the alternative?
 
I posted two sets of code but I was under the impression I shouldn't have done that, so I deleted it from the chat.
 
You can post them on ideone.com and then paste the links here.
 
7:13 PM
OK. Let me do that.
 
@DiscreteGenius My immediate reaction would be to wonder why you're putting them in a vector at all. Why not just read a word, convert to upper case, print out, if multiple of 8, print a new-line, repeat 'til EOF?
 
@JerryCoffin That reminds me of the if (line & 7 == 7) bug I had a couple of days ago. The conditional will trigger every 2nd line instead of every 8th. See the problem? :)
 
@JerryCoffin I'm learning to use vectors.
 
@Ell congrats!
 
@DiscreteGenius Ah, that would probably be a reason to use a vector.
 
Ell
7:15 PM
@CheersandhthAlf thank you! :)
ugh, maths exam tomorrow. Must study! bye all
 
@FredOverflow there's compiler warnings for that
 
@MooingDuck Not if you're lazy and just call gcc foo.c from the command line ;)
 
@Ell Have fun.
@FredOverflow Get a jazzed up build with warnings on by default!
 
@RMartinhoFernandes Builds? I don't need builds for my toy programs.
 
7:17 PM
@FredOverflow also I can't think of a variant of that that would trigger every seven. Just adding parenthesis will make it trigger 1/8th of the time or something wouldn't it?
 
@MooingDuck Isn't 1/8th exactly what we want? If for some reason you need every 7th, use if (line % 7 == 6).
 
@FredOverflow You need a compiler, right?
 
@FredOverflow I couldn't derive that intent from your statement
 
> The conditional will trigger every 2nd line instead of every 8th.
 
@FredOverflow that one would never trigger
@FredOverflow oops
@DiscreteGenius I didn't look at the code, but I note they display different things on the screen
@DiscreteGenius std::transform(vStr1[ix_v].begin(), vStr1[ix_v].end(), toupper(); is one line instead of 6, and far faster.
@DiscreteGenius (removed)
 
7:22 PM
Slowpoke looks like a naked Psyduck
 
@MooingDuck Doesn't std::transform take 4 arguments?
 
@MooingDuck isn't there a wrong parenthesis? anyway, it's UB to use toupper that way except for char set restricted to ASCII
 
@MooingDuck That sounds fantastic! LOL But, sadly, I'm have not learned that in my book.
 
@FredOverflow checking... yes
 
@DiscreteGenius Just look trough the standard library algorithms and utilities on cppreference.com
 
7:23 PM
@MooingDuck cnt is a counter used for counting 8 words per line. Right?
 
@DiscreteGenius i think it's good that your book didn't teach that usage of toupper, because it's wrong. on the other hand, it should have taught std::transform, which is very useful. and fast, as the duck notes.
 
@FredOverflow can I just "std::transform(vStr1[ix_v].begin(), vStr1[ix_v].end(), vStr1[ix_v].begin(), toupper);"? not sure
@DiscreteGenius I misread, yes it is
 
also, someone should have taught me to spel
 
@MooingDuck What exactly are you not sure about? The iterators can be the same, but I have no idea about that toupper issue Alf is mentioning.
 
@MooingDuck no, that's UB in general
 
7:25 PM
@CheersandhthAlf toupper isn't wrong for ASCII. As long as your recall it only works on ASCII, you're fine
 
yeah, that's what i said
except, nobody's doing pure ascii these days
 
No, no, no. My book told me how to use toupper() to modify characters of strings. I used that knowledge and applied it to the question. I have not learned std::transform() yet
 
only microsoft...
 
In case you're wondering, my book is C++ Primer 4th, by Lippman :D
 
@CheersandhthAlf micosoft doesn't use ASCII for anything as far as I can tell. They just also provide an ASCII interface for people who want to keep compiling bad code. I hear most of them are simply wrappers around the UCS2 variant.
 
7:26 PM
@DiscreteGenius By the way, what book are you learning from?
 
@FredOverflow toupper only accepts positive argument, plus EOF
 
1219
Q: The Definitive C++ Book Guide and List

grepsedawkThis question attempts to collect the few pearls among the dozens of bad C++ books that are released every year. Unlike many other programming languages, which are often picked up on the go from tutorials found on the Internet, few are able to quickly pick up C++ without studying a good C++ book...

 
@FredOverflow ROFL
35 secs ago, by DiscreteGenius
In case you're wondering, my book is C++ Primer 4th, by Lippman :D
 
7:27 PM
@MooingDuck microsoft has documented the c++ basic character set of visual c++ as ascii. of course that's wrong. it's really Windows ANSI (as per the getacp function)
 
The Book List. Seriously
 
@DiscreteGenius you don't need transform, but modify the strings directly instead of making copies back and forth.
 
Wtf does this mean in a Makefile: $(CC) $< -o $@
CC I understand
 
@CheersandhthAlf More in his own book :)
 
But $< and $@ ??
 
7:28 PM
    for (string::size_type ix_s = 0; ix_s != sStr2.size(); ++ix_s) {
        vStr1[ix_v][ix_s] = toupper(vStr1[ix_v][ix_s]);
    }
 
@ManofOneWay $< is the first dependency item (source)
$@ is the full name of the current target
 
@sehe should i post link again? i think i update pdf first
not much more new, but a little ...
 
@CheersandhthAlf Isn't it on the book list :) ?
 
it must first become a book!
if it does...
 
Who the hell came up with $< and $@? Couldn't they type out the name?
 
7:29 PM
@CheersandhthAlf Is it? I never noticed. I put unciode chars in my comments all the time and it works fine.
 
the toupper function is documented in the C standard
 
@Pubby There was not enough memory for meaningful names back in the days.
 
@CheersandhthAlf Well, you might post a link. Your chapter on encodings, especially windows console output was quite in-depth. i learned a few things (like: really stay away :))
 
@MooingDuck as a consequence of being windows ansi it's not fixed. it depends on your windows configuration. which means the result of compiling, generally also depends.
 
@sehe oh yeah, forgot about the windows console. Alf is definitely right about that. That is rediculous.
 
7:31 PM
lol?
 
@sehe Dependencies like the included header files?
 
Nope, that's prerequisites. E.g.:

rule: source1.cpp source2.cpp | h1.hpp h2.hpp
 
What is this shit?
 
$@ == rule, $< == "source1.cpp", $^ == "source1.cpp source2.cpp"
@FredOverflow To much vertical real estate
 
7:34 PM
i just made new pdf, but upload to google is sloooooow
 
A new pdf of what?
 
@FredOverflow looks like an ad targeted at pedophiles to create awareness that their victims don't like it. That is a common fallacy with pedophiles: they are often convinced that their victims liked doing the things they wanted them to, and they consented to it.
By taking the point to the extreme, the pervs might suddenly sense that something is off in that picture?
 
Of course nobody wants to be raped.
 
But it takes a shock campaign to tell some people that. Apparently
 
it's at about 85%
^ the lastest, in the very middle of some editing... but, there are two or three new fancy figures :-)
 
7:38 PM
There's more where that came from:
 
the toupper crash dialog is shown at bottom on page 43 (as numbered within the pdf)
well, actually it's isalpha. the other family functions have the same UB issue, but I don't know about the checking in the Visual C++ runtime library.
“The header <ctype.h> declares several functions useful for testing and
mapping characters. In all cases the argument is an int, the value of which shall
be representable as an unsigned char or shall equal the value of the macro EOF. If the argument has any other value, the behavior is undefined.”
^ N869 (C99 DRAFT) §7.4/1
 
uploaded new version of Wide specification
 
Can I std::cout a bitset in... bits?
wow I can. Awesomeness.
 
Morning.
 
7:52 PM
Evening.
 
Winning.
 
Question (again): can you friend main?
 
Can't use main.
 
Comments, please, on C++ IDEs for Mac OS X
 
Rofl. Someone lists this is their personal website in their SO profile: adnandoric.com
That is a high quality website. Clearly, he put a lot of work into that.
 
8:01 PM
@SamDeHaan That's some hi-tech stuff!
 
@RMartinhoFernandes but main would have access to a class's private parts.
 
I'm currently using XCode 4.3.2 on Mac OS X Lion. I want an IDE, not command, but I'm tired of using XCode. What is the next reputable IDE for Mac? I'm writing in C++.
 
@SamDeHaan At least, the HTML is clean
 
@sehe If you can even call it HTML ;)
 
@DiscreteGenius I didn't see I saw HTML. But it is clean, and absent
@rubenvb Yes. Bit rough 'round the edges though if I remember well. Mmm. I might be rememembering about parsing
@SamDeHaan And he knows how to prioritize
 
8:16 PM
Is there some readable printf of integer implementation I can study?
 
@DiscreteGenius I have the same problem. Well, almost. I'm on Snow Leopard.
 
If I have several registers I want to use throughout the program, is it a bad practice defining these Registers within the Register.hpp file?
http://ideone.com/2d5aA
 
@ManofOneWay (a) why not pass an array of them (b) why not make them const, then?
 
@EtiennedeMartel After reading a few of the forums, I guess XCode is the standard for Mac, with not much choice for alternatives..XCode is OK, I just don't like the way it handles code correction/suggestion.
 
@sehe (a) I want to be able to access just one at a time (b) Thank you =)
 
8:25 PM
@ManofOneWay It looks like you may be overdesigning things a bit. What's wrong with an enum with just the registers? Use bitmasks for extra info (RegisterFlags). Just passing around integral constants beats the crap out of using shared data by reference
 
I've asked a very un-SO like question :-S
 
Nice question
I suppose, a promise can be broken, the future already is :)
 
@sehe Oh, I totally love the names std::atomic_future and std::broken_promise.
4
I have no idea what either do.
 
@KerrekSB Impress the ladies
 
@sehe Yeah, I'm trying!
 
@EtiennedeMartel Is that an atomic future?
 
No, it's an atomic teabag.
But it's quite similar.
 
@DiscreteGenius Going back to the question about printing words out in upper case, 8 per line, here's my idea of how to do it (note that most of the code here is really intended to be in a separate header):
 
Both are atomic.
 
@EtiennedeMartel Halo is weird...
I'll play a round of Psychonauts while waiting for some code to come in on that question. Got it from the Humble Bundle. Good soundtrack.
 
8:35 PM
@KerrekSB Tried Bastion? Because that has a good soundtrack.
 
@JerryCoffin Really? What's with the fake output iterator? Why would you use both transform and a custom output iterator? Why not just for_each with a functor/lambda?
 
@EtiennedeMartel Yeah, but I didn't find it otherwise engaging. It bored be somehow.
 
@JerryCoffin Oh, and why to you copy all input tokens into a vector, only to stream it out right away? Why not transform std::cin into std::cout directly?
 
hello , is there a dynamic array , with which you can find the minimum of integers?
 
8:42 PM
std::set is sorted.
 
@georgemano That doesn't make any sense :)
 
std::vector is a no-overhead dynamic array
 
a dymanic array where you put inside it integers and after puting them all you can find the minimum of them
 
Finding the smallest value in it is a piece of cake.
 
perhaps priority_queue, if that was the name, can be regarded as an array
 
8:44 PM
std::set sorts automatically, but all values must be unique.
 
@CheersandhthAlf It is an array if you use vector (which is the default) as its underlying container type.
 
@JerryCoffin Oh, and operator() in upper_string should be const, really :)
 
so ... what should i use ? vector , priority_queue or set?
 
std::vector<int> foo{1, 5, 8, 0};
std::sort(std::begin(foo), std::end(foo));
 
@georgemano What is your use case?
 
8:46 PM
i will have values that will be entered in the array by the program , i dont know them now , and after i
will program it , so it gives me back the minimum of the values
and after clear it because , i might use it again
 
Use std::set and then just use my_set.front().
Though you can do this more easily without a container at all.
 
@RadekSlupik set has no front.
 
@RadekSlupik how ?
 
@georgemano those are all very very different
 
@georgemano what are you using the array for?
 
8:49 PM
:4096970 get()?
 
Nvm, brainfart, got it :P
 
int value;
int lowest = INT_MAX;
while (std::cin >> value) {
  if (value < lowest) lowest = value;
} // or something like that
 
@EtiennedeMartel Yeah get() gives you the pointer.
 
@ScarletAmaranth: you can't access the internal pointer storage of a unique_ptr, but you can reseat it. the reason is that if it provided access to its internal storage, then it could not maintain its destruction guarantee.
 
@EtiennedeMartel ("unwrapped")
 
8:51 PM
:4097013 well you asked, i just gave you the rundown. since i have no need to ask about it, i'd trust myself. ;-)
 
what is unwrapped?
 
@CheersandhthAlf Thanks, sry :)
 
@sehe I asked that originally, but he said he was learning about how to use vector, so without a vector...
 
sbi
@sehe Yeah, I found this out with another picture, where I needed to cut off some artifacts. :(
 
@sehe Oops, quite right.
 
sbi
8:53 PM
@StackedCrooked I'd rather spend my time doing other things. :-/
 
Why does this print out 1 ?
http://ideone.com/XXtXF
 
@sehe Because for_each sucks. Yes, in this particular case, the suckiness wouldn't be quite as obvious as usual, but you'd still be a long ways from the SRP with a lambda that converts to upper case, and deals with formatting items to a stream.
 
@ManofOneWay because it's a function address, and it's converted to bool, which is the only applicable overload of operator<< because function pointers don't convert to void*.
was that an interview question?
 
user457812
Sounded like one.
 
Ah okey
No I tried it now
 
user457812
8:56 PM
Albeit lacking a circuitous story to go along with it
 
and didn't understand what happend
 
@CheersandhthAlf Sorry again, makes perfect sense now :)
 
he he :)
thx
 
@CheersandhthAlf How can it be a function address? He declares v1, but (as usual from the most vexing parse) never defines it.
 
@JerryCoffin well the definition could be in some other file, yes?
i think it must have been, since the code compiled and executed
unless compiler was very smart, noted that it's not really really used, and optimized?
 
8:58 PM
That's the only file I used
 
@CheersandhthAlf ideone doesn't handle multi-file compilation (TTBOMK). Looks like a bug to me.
 
ok then it optimized the function away
agree
 
Then why doesn't this work? ideone.com/uynuE
 

« first day (605 days earlier)      last day (4326 days later) »