« first day (79 days earlier)      last day (4878 days later) » 

12:44 AM
I'm not going mad here, am I? There's no strict language requirement to call a destructor (or cause a call to a destructor) on a dynamically allocated object, is there?
Obviously is almost always bad practice not to.
0
A: Does C++ require a destructor call for each placement new?

Charles BaileyIf I understand your question correctly you have a C object in memory and you want to initialize a C++ object with the same layout "over the top" of the existing object. CppObject* cppobject = new (cobject) CppObject; While there is no problem with not calling a destructor for the old object -...

 
12:56 AM
@CharlesBailey Your answer matches my understanding.
 
@JamesMcNellis That's some reassurance, thanks.
 
 
2 hours later…
3:07 AM
@CharlesBailey: I think 3.8/1 is the relevant specification. It says that the lifetime of an object ends when "the storage which the object occupies is reused or released." Constructing a new object over the top of an existing object obviously "reuses" the existing object's storage, so its lifetime ends.
 
3:36 AM
@marcog You meant std::set, right? Not STL. :)
 
4:19 AM
BTW @TomalakGeretkal is a guy from ##c++ land. From where Roger Pate came =)
 
4:30 AM
OMG! Check out the number of views
33
Q: Printing 1 to 1000 without loop or conditionals

Saurabh GokhaleTask: Print numbers from 1 to 1000 without using any loop or conditional statements. Don't just write the printf() or cout statement 1000 times. How would you do that using C or C++?

 
@PrasoonSaurav last time I saw was 10k, then few I checked again, was 12k... do you know what's the most viewed question?
 
2154
Q: List of freely available programming books

KaranI'm trying to amass a list of programming books with open-source licenses, like Creative Commons, GPL, etc. The books can be about a particular programming language or about computers in general. What are some freely available programming books on the Internet?

Viewed 181K times
 
@JohannesSchaublitb And you :P
 
4:52 AM
@PrasoonSaurav first time I see that one, thank you :-)
 
:P
@PrasoonSaurav someone post it to reddit and it will be famous xD
 
go for it
anyway, nice to be hear on SO. can't wait to teach you guys lots of stuff.
er I mean learn lots of stuff from you guys :)
 
 
1 hour later…
6:16 AM
@JohannesSchaublitb It seems someone has already posted the link there.
 
 
2 hours later…
8:37 AM
@PrasoonSaurav oh haha
 
9:16 AM
when debugging a template function, you should normally be able to watch local variables etc right?
 
@Tony That depends on the quality of your compiler / debugger.
 
VS
is my debugger
 
9:38 AM
@CharlesBailey: I missed that distinction :( still seems too pedantic to really help, though
you definitely answered the first part of what he asked, but he didn't really ask about what he wanted :)
 
is this wrong inside a struct:
	inline bool has_attributes()
	{
		return attributes..empty();
	}
???
cause it can't break in there for some reason?
(I saw the syntax error)
 
9:52 AM
@FredNurk Huh, I'm not sure what you're replying to?
 
@Tony looks fine; however, debugging an optimized program can be unexpected. even at "no optimization", that function is likely inlined which, depending on your compiler and debugger, might do different things when you set a breakpoint
 
@FredNurk I'm not wrong again, am I?
 
@FredNurk I am able to debug it now
thx
 
@CharlesBailey no, you're right as near as I can interpret c++03; but that interpretation (of being able to change values after the allocation function and before the ctor) isn't close to how any c++ implementation of which I'm aware does things
I didn't mean it as a slight: c++ is full of that kind of crap, and it's why using only the standard in real contexts is so hard
 
@FredNurk True, but some compilers zero-initialize things which they could leave uninitialized which is functionally equivalent and just as damaging to what the question asker was hoping would work.
 
10:05 AM
I have a weird situation where this statement is not entered by my machine: if (!false)
how is that possible?
 
that is always done in the allocation function, but that later is why I said he didn't ask about what he wanted to know :)
 
am I missing something?
 
@Tony: the optimization comment seemed to help before, are you sure this isn't a similar situation? do you have UB anywhere?
 
Let me show you what i've got
template <typename T>
T find_attribute(const std::string& attribute)
{

	std::vector<boost::shared_ptr<node> >::iterator nodes_iter = _request->begin();

	for (; nodes_iter != _request->end(); nodes_iter++)
	{
		bool has_attributes = (*nodes_iter)->has_attributes();
		if (!false)
		{
			size_t sz = (*nodes_iter)->attributes.size();
			std::vector<node::attrib>::iterator att_iter = (*nodes_iter)->attributes.begin();
			for (; att_iter != (*nodes_iter)->attributes.end(); att_iter++)
			{
				if (att_iter->key.compare(attribute) == 0)
 
is false really a function's return value? (have you messed up something in translation to here?)
 
10:07 AM
I have this in the private part of a class declaration
 
why are you writing (!false) literally?
 
the !false statement is at test
 
@FredNurk: This was a version of Visual Studio, IIRC, and it definitely didn't happen in the allocation function as it was a debug build which would have filled the allocated memory with 0xcc.
 
because the has_attributes was showing odd behaviour
doing the opposite of what it was supposed to be doing
 
@CharlesBailey: I haven't used VS for 5+ years
 
10:08 AM
@Tony: are you completely sure that one of the two for loops wasn't just empty.
 
it should be if (has_attributes) but the if statement was being entered when that was false instead of true, so I was testing the logic of things...
 
@FredNurk: Lucky you.
 
yea but it enters this if statement only on the second iteration
not on the first?
how is that possible?
 
chat's "see full text" is useless :/
 
lol
 
10:11 AM
@Tony: why are you checking for attributes instead of just looping over them? an empty loop sometimes is usually better than always testing and then sometimes looping
if you catch that last bit :)
 
@FredNurk I put in that test just to see if there was anything in my underlying vector, I will take it out again after i verified that this function works as desired
however it isn't working as desired
 
for node in request: for attr in node: do_something_with(attr) # pseudocode, but I was saying it's no big deal if the inner loop body doesn't execute
 
my problem is that a if (true) statement is not entered by my computer
 
well, you took sz; decrement it each loop, then assert(sz == 0) at the end
we know how the language works, and if (true)'s body is executed, :P that's why this is frustrating: you have a problem elsewhere and we can't see the whole picture
 
@Tony If that really is true then you need to change your compiler.
 
10:15 AM
@FredNurk not sure exactly what you mean, however when i step through it, on the first iteration it skips the if statement
 
have you heard of "undefined behavior"? I know I've read something decent on SO about it, but nfi where that is now
those links to the right at "Don't be vague, be an ace; write a proper test-case!" are good too
 
@Tony: The if statement does nothing so it's likely that it doesn't generate any code and you can't stop where there isn't any code. If you really want to know whether the if statement is entered put a statement with side effects (e.g. printf) immediately inside the if statement.
 
I've heard of undefined behavior
 
sorry, it's late and I'm fried, but I can't help solve "if (true) is broken", just not enough info
 
pfff that makes things really hard
 
10:18 AM
good ol' printf debugging 1.0
(printf debugging 2.0 is unit tests)
 
@FredNurk well thanks for trying anyways, I do appreciate
 
@FredNurk It's old; it works; it's quicker than staring at the code for hours and hours.
 
a "classic" debugger works great if you know (some) asm and implementation details :)
but it's often not very good as a language-level debugger for c++
 
@TomalakGeretkal std::set is part of the STL, not so?
@PrasoonSaurav That's because I posted the question on proggit
 
@marcog you rock
 
10:27 AM
I think I'm getting a tiny bit better at C++0x.
Does anyone know that status of the proposal that [[override]] and friends should become (possibly context-sensitive shock! horror!) instead of attributes before C++0x is finalized?
 
not the latest status, but, combined with msft's stance on attributes, the last I read of it was leaning towards keywords
 
@Charles they accepted the proposal to make override context sensitive
[[hiding]] becomes new, and "base_check" becomes explicit
@Charles this is incorporated into n3225 already, at 10/9
ah, and "final" becomes context sensitive too.
 
Oops, opened an old version of C++0x by mistake.
Not sure how I feel about final and override. It feels like Java or C# now.
 
i think i like it more than [[final]] or fin_decl or such
 
@JohannesSchaublitb Oh yes, definitiely.
 
10:39 AM
context sensitive or not... doesn't really matter IMHO
 
Oh but context sensitive opens up the possibility for good obfuscation.
void final () final; void
 
indeed, i already thought i would start a troll quiz once gcc supports them. maybe i would go with typedef void override(); struct A explicit : B { override override new override; }; haha
 
Muhahahaha. Our C++ interview test will become virtually (override?) impossible.
 
hm wait that won't work. reordering rule bites. first override in class should be ::override i suspect
lol
 
C++0x has so much in it. noexcept is an operator too? Wow.
 
10:46 AM
so they could say void swap(C &c) noexcept(noexcept(swap(c.m, m)));
 
@JohannesSchaublitb I need to go and make some coffee; my head's about to explode (again).
 
@JohannesSchaublitb Ah, got it! (The coffee, that is.)
 
@Charles for example at 20.3.5.2/34
 
11:04 AM
@marcog i think this gets you a second publicist badge =)
 
11:25 AM
@JohannesSchaublitb Unfortunately those are once-off badges :(
they should introduce a new one though: 100,000 unique IPs
it's already got 40k
 
 
5 hours later…
4:07 PM
@marcog Not so. The C++ Standard Library uses the namespace std; as far as I am aware, the STL does not.
Your confusion may stem from a widely prevalent and deeply flawed use of the term "The STL" to mean the C++ Standard Library, when it does not.
 
What type is pointer in C++ ?
For example
MyClass*
is it integer or unsigned integer ?
Am I even asking right way ?;p
 
Huh?
A pointer is a pointer, not an integer.
I'm not sure about its signedness; at a complete guess I'd say it's implementation-dependent, though it might make more sense to be mandated as unsigned. Certainly you should not be worrying about it in code.
Also, this is a collusion lounge; you can post questions on the StackOverflow site proper. :)
 
@TomalakGeretkal A pointer isn't signed or unsigned, a pointer is not an integer or a number.
Pointers and signedness just aren't compatible concepts.
 
4:27 PM
@TomalakGeretkal It's documented as part of the STL
 
@Charles As I figured, but the underlying data will internally, in sane implementations, be built on top of an unsigned or signed integer, I'd imagine
 
and I know of the STL as the Standard Template Library
 
@marcog: I see no "std::" there.
The STL has a "set" container, and std::set in the C++ Standard Library was based on it.
 
Really?
I wasn't aware of that
 
Just because there's "Template" in the name doesn't mean that anything that is a template is automatically part of it :P
@marcog: Many people aren't, which is a shame.
 
4:29 PM
So how does one use the STL set?
 
@TomalakGeretkal Not necessarily. E.g. in x86 32-bit registers don't have sign, but there are operations that treat them as either signed or unsigned numbers and others that treat them like addresses.
 
Unfortunately, many prolific and otherwise respectable authors continue to munge the terms together, because they don't think it matters. I and others disagree.
@marcog You posted the link to the STL documentation, so now you know how to use the STL set. :)
@CharlesBailey Fair enough
 
@TomalakGeretkal STL set is in algorithm.h, right? Where's std::set?
 
std::set is in <set> that ships with your favourite standards-compliant toolchain.
 
Other operations (lea) treat them as addresses. Wondering whether pointers have signedness feels like a step in the direction of muddled concepts. IMHO.
 
4:31 PM
Oh, of course I get you now
 
I have no idea at all how the STL headers are laid out; I have never used the STL. Very few people use it now.
@CharlesBailey Absolutely.
 
@TomalakGeretkal Thanks for enlightening me!
 
@marcog: :)
 
@TomalakGeretkal std::set is the more commonly used, right?
 
Vastly.
It saddens me that even the SGI STL documentation pretends that their set is defined in the "standard header <set>", right before admitting that it's actually to be found in the old STL header <set.h>. There is simply no need to have confused everybody so.
Just because the interface was taken and [mostly] absorbed into the standard.... back in 1998, two standard iterations ago.
 
4:35 PM
cplusplus.com is also to blame
2
"C++ : Reference : STL Containers : set : set" uses <set>
 
Yes.
Many references get it wrong too.
In particular, cplusplus.com is just riddled with errors in general.
The idea seems to be in general "who cares? we all call it the STL now" but it leads to a bit of a mess when you start bringing in the differences between the STL and the various incarnations of the C++ Standard Library, and there are a few. Particularly with C++0x.
2
And it's just... wrong, godsdammit!
 
It causes problems when different places / people say different things, and like with us now I was almost certain I was right
 
Unfortunately, other than pointing out that there is no instance of the text "STL" in the standard whatsoever, there is not much to persuade against the sheer volume of resources and documentation that get it wrong. So I and my cohorts are fighting a losing battle, despite being 100% correct. :)
Spread the word, marcog. :)
 
@TomalakGeretkal Oh you can be sure I will!
 
4:49 PM
Let's see if it picks up :)
 
ahha
this'll be interesting
 
5:09 PM
d'oh
my webserver isn't set up for this volume of requests
 
 
1 hour later…
6:25 PM
@TomalakGeretkal: you should ask this guy what's related; point out basic_ostream<CharType,Traits> is not, in this way, "related" to basic_string<CharType,Traits,Alloc> and I'm sure there's another good example of something not in the STL, but more closely related to the template facilities of the stdlib than the rest
 
sbi
7:22 PM
room topic changed to C++ -> Lounge: For those who know that the STL is not the stdlib*
@sbi And it was about time, too, that the description changed. It has been unchanged for weeks!
 
@sbi Some of us have no objection whatsoever to using the term "STL" to refer to the components of the Standard Library that originated in or are derived from the SGI STL.
 
sbi
@JamesMcNellis But those few, um, misguided individuals around here would still know that the std lib is not the same as the STL, no? :)
 
7:37 PM
who defines what words mean anyway
isn't it the majority of users anyway in the long run
 
(does it mean that "Effective STL" was actually badly titled ?)
 
lol
i should post my "while(1) ; will be undefined behavior in next C++" question to reddit and see all the system level programmers scream haha
 
@JohannesSchaublitb Absolutely not, if the majority defined what words mean then being right would be devalued ;) .
 
@CharlesBailey In the long run, however, the meanings of words change based on common usage.
 
sbi
@icecrime No. "Effective STL. 50 Specific Ways to Improve Your Use of the Standard Template Library" deals with the STL (that parts of the standard library which come from the original SGI STL) only, which is why it isn't a misnomer.
 
7:46 PM
@sbi According to some people, it is misnamed.
 
hmm... what a coincidence
I was just thinking about while(1);
or something like that
I have a question but I didn't find it good enough to ask on the main site
Is it very bad to use "while(x);" to make a pause in a thread?
 
sbi
@JamesMcNellis Replied accordingly.
 
@BlaXpirit: avoid busy waits where you really don't need them, and you often don't need them
 
@sbi that's just wrong I think. i don't believe he uses "STL" to refer specifically to those parts that in the past was present in the original STL. rather he just refers to the C++ standard library
 
sbi
@JohannesSchaublitb "he" being Scott Meyers?
 
7:58 PM
whoever wrote "Effective STL." i have no clue. but I believe it is him
 
@JohannesSchaublitb No, it's just about the STL parts of the Standard Library. His other two books, Effective C++ and More Effective C++ are more general books. Effective STL covers just the containers, iterators, algorithms, and functors.
 
Glad I asked :)
 
sbi
@JohannesSchaublitb It's by Scott Meyers, its name is "Effective STL. 50 Specific Ways to Improve Your Use of the Standard Template Library". I was worried that he would have got this wrong, so I pulled my copy from the shelf to make sure. It really is only about the STL, not anything else from the std lib.
 
@sbi it touches on strings, but that's minor
 
sbi
8:01 PM
@FredN I know, but std::basic_string was STLified when the STL was added to the std lib, so it really is an STL container.
 
@JamesMcNellis: no, it is not
 
s/originated in/is part of/
 
sbi
@JamesMcNellis I think this is wrong. There already was a std::string class in the std lib when they added the STL.
 
In any case, basic_string is a container.
 
unfortunately
it presents an awkward subset of the interface, from a container perspective, so it's usually more trouble to treat it as one
 
8:06 PM
i argue that he misnamed his book then. too bad
 
based on string? no, I said it was minor
 
sbi
@Johannes, are you drunk or are you trying to deliberately be obtuse?
 
i'm neither.
i think he just misnamed his book. we're all human after all
if he deliberately restricts his elaborations to the stuff that was in SGI STL, instead of deliberately restricting it to the Standard Template components, that is.
I can see why he would call it "STL", when he would just collegially refer to the template parts of the Standard library.
 
sbi
@JohannesSchaublitb The term "STL" is wrongly used to refer to the whole of the standard library, but it's rightly used to refer to that part of the standard library implementing the containers, algorithms, and iterators that make up the idea of an "STL".
2
 
i think it would be as if you would write "Effective C Programming" and the book would be about C++ in details (thus assuming 'a' has type char), but would restrict itself to the functionality of C on the big picture.
that would equally be totally retarded
 
sbi
8:11 PM
@JohannesSchaublitb Assuming you're right about this (which you're not) - if you want to write a book about that part of the standard library that stems from the STL, how would you describe the topic without using the term "STL"?
 
I wouldn't do such a book in the first place
i doubt the utility of having a book that artificially restricts itself to a subset of the Standard library just to be able to be called with some term.
instead I would do a book about the entire standard library and restrict myself to the entire set of template components or entire set of containers/iterators/algorithms, and maybe call it "Effective STL". but i wouldn't do so because i would only cover what was originally called STL in the past
 
sbi
@JohannesSchaublitb Well, the book is great. It sums up 50 rules of thumb in an easy-to-remember format, well explained, entertainingly written, about that part of the standard library, that had Here Be Dragons written over it, when it became part of the standard.
3
 
maybe i would also call it "Effective C++" with subtitle "Containers, Iterators and Algorithms". I have no clue
 
sbi
@JohannesSchaublitb There already was an "Effective C++".
 
so if i would call it "Effective STL" i would still show all containers that C++ has. For example, i would also show std::array<> if it were about c++0x. even though it wasn't in the original STL library.
 
sbi
@JohannesSchaublitb As I said: There already was an "Effective C++". It lists what Scott considered the 50 (I think 52 in the latest edition) most important rules of thumb for C++. "Effective STL" lists what he considers the 50 most important rules about the STL.
And, yes, in my universe, "STL" encompasses std::array<>.
2
@JamesMcNellis I can't help but agree to those saying this a wasted effort, considering the brands that guy stocks.
 
8:45 PM
Hello all, it concerns C but I really want to ask: "Which functions in the C standard library commonly encourage bad practice?" as inspired by the comments on this question: stackoverflow.com/questions/4580329/… Do you think, it being so subjective, it'd be appropriate to ask?
 
9:09 PM
Any expert willing to take a look on this : stackoverflow.com/questions/4583022/…
I'm really skeptical over the some_template<"abc"[2]> thing
 
@Ninefingers gets is one such
 
Whoa, what is all this heated STL terminology discussion? Can we please get back to bashing Singletons or something? :)
4
 
Wait, std::something or SGI something ?
 
To me, "STL" means nothing more than "Standard Template Library" and as such includes basic_ios, basic_string, std::ctype and whatever other template there is :)
 
@JohannesSchaublitb ! Please tell me that this can't be
 
9:20 PM
@icecrime that's not valid
 
Not even in C++0x right ?
 
i'm not sure about c++0x. but i don't think so
 
thanks, this really confused me
 
in c++0x they want to allow constexpr int f() { constexpr int a[] = { 1, 2, 3 }; return a[0]; } though
 
and a constexpr can be used as an argument to a non-type template parameter I presume ?
 
9:23 PM
this is already quite "fun" imho and doesn't seem to be too far away from "foo"[0]
@icecrime exactly
like array<int, f()> a;
the above constexpr array stuff isn't in the draft yet. i have only seen it being discussed by them and they found it shouldn't make any problems.
 
@JohannesSchaublitb Are you sure you can define local variables in constexpr functions? I thought the body of such a function must consist of a single return statement.
 
@FredOverflow in the current draft, that is the case only
 
@JohannesSchaublitb But they are still considering changes? Will they ever complete that C++0x thing? Come on, it's already two years late :)
 
@FredOverflow maybe i misinterpreted their intend and they want to have it in in the next-next spec only. I will see whether i can find the discussion again
@icecrime hmm looks like "foo"[i] is valid in c++0x
it forbids array to pointer conversions only in the case of "an array-to-pointer conversion (4.2) that is applied to a glvalue that does not designate an object with
static storage duration;"
 
sbi
@JohannesSchaublitb What on earth has std::basic_ios to do with the idea to generalize sequences and algorithms, gluing them together with iterators?
Oh wait. This was sarcasm, right?
Sorry.
 
9:36 PM
@sbi it has nothing to do with that idea
but it's a template. so i take it as part of the standard template library
 
@JohannesSchaublitb Certainly you know about Stepanov's attempts to separate containers from algorithms via iterators? This is what people mean when they talk about the "STL". Not "any standard library component that has to do with templates" ;)
2
 
@sbi Well, yeah. But it has potential! I wonder if I could build a robot with my LEGO Mindstorms kit that would fetch beer for me :-D
 
not sure whether they mean that. for example: stackoverflow.com/questions/1096291/…
3
Q: How to format my own objects when using STL streams?

rveI want to output my own object to a STL stream but with customized formatting. I came up with something like this but since I never used locale and imbue before I have no idea if this makes sense and how to implement MyFacet and operator<<. So my questions are: does this make sense and how...

 
@FredOverflow the former is often not what people mean
 
It's interesting to see that we have such a diversity of opinions. We have Tomalak and others that think that "STL" refers only to the SGI STL, we have sbi, myself, and others that think that it's the container, iterator, algorithm, and functor libraries, and we have litb and others that think it's anything that is a template...
 
9:46 PM
you can endlessly debate it, or instead refuse to use the term yourself and gently remind anyone that STL != stdlib, when they push the issue
 
@JohannesSchaublitb: I'm willing to broaden my definition of [stl] if it means I get gold-badged in it faster :-D
 
@JamesMcNellis: is "the Eiffel Tower" just any tower of iron? "*the* STL" isn't different, though it's unfortunate to have been originally named with "standard"
 
hehe
oh mainsite is down
seems like the chat is on a separate server?
 
@JohannesSchaublitb Oh; I thought I had just refreshed it too many times in the last ten minutes trolling for questions to answer.
 
9:48 PM
and it's back...
 
sbi
10:25 PM
@JamesMcNellis LOL! You troll for answers? That opens a whole can of... new meanings to the term "straw polling".
 
sbi
10:49 PM
This seems like a compiler bug:
0
Q: templates, typename, lambda -> dependent names not dependent??

Noah RobertsConsider: template < typename Something > boost::function<void()> f() { typedef typename Something::what type; return [](){}; } In this code you need the typename because 'what' is a dependent name. But consider this: template < typename Something > boost::function<v...

 

« first day (79 days earlier)      last day (4878 days later) »