« first day (368 days earlier)      last day (4570 days later) » 

4:00 AM
@RMartinhoFernandes Why a frowny face? Compiling is fun!
 
I don't have anyone around to practice swordplay with.
 
Doesn't seem very up-to-date for mingw :(
@RMartinhoFernandes You can try but there's the possibility those builds are not recent enough. My snapshot is 20111010 FWIW.
The joys of bleeding edge where one week can make all the difference.
 
Six days.
Hmm.
 
Hey, it's binary. Nothing to lose right?
 
I'm already dropping it to a folder.
 
4:27 AM
template <typename, typename> class foo {}; template <typename... T> class bar : foo<T...> {}; template class bar<int,int>;
This should compile?
 
I think so. Let me try.
 
error: wrong number of template arguments (1, should be 2)
error: provided for 'template<class, class> class foo'
 
Same.
 
So, what bug was fixed?
Wasn't it about expanding a pack into a fixed size argument list, like this?
 
'Sorry, unimplemented: cannot expand into fixed-length list' or to that substance
 
4:33 AM
Lemme switch and see what 4.6 says.
 
The template template parameter workaround works btw.
Same error with 4.6.
 
Yeah, same thing.
 
I guess that's another bug then?
 
But you said it was fixed! I feel robbed.
 
But it was: you won't see the message anymore.
 
4:35 AM
lol
Ah!
template <typename, typename>
class foo {};
template <typename... T>
class foo<int, T...> {};
It's about partial specializations.
 
Is it?
 
That sample triggers the error.
 
It's not quite clearcut as template<typename> struct foo; template<typename... T> struct foo<T...> {}; is fine. I wouldn't waste too much energy trying to understand what's going on unless you want to submit a patch report, or write a patch.
 
:(
If I was interested in patching GCC I'd be building it!
 
Do you guys know what is wrong with this code segment?
std::istringstream ss;
	char temp;
		std::cin >> line;
		ss = std::istringstream(line);
		expression.clear();
		while(ss>> temp)
			expression.push_back(temp);
		expression = to_postfix(expression);
		print_exp(expression);
when i input. it exits.
line == string
 
4:46 AM
What does the input look like?
 
numbers, e.g. " 3 + 5 / 3"
line is a std::string
 
std::cin >> line does not read a line.
 
just one input?
 
the doc looks much better when i converted to PDF with OpenOffice. the only snag was a single "widow" line (pagination error) in OpenOffice Writer. i had to check paragraph style and say OK and then, with OK on the styles it already had, it fixed it.
 
4:47 AM
@oorosco Reads until whitespace I think.
To read a line you need std::getline.
Why am I have a feeling of déjà vu?
 
lol. this is slightly dif :)
i dind't realize that cin>> was limited
 
It's not limited, it just doesn't do what you want.
 
std::getline(std::cin, line);
 
For std::string it reads a word.
 
does that look right?
 
4:49 AM
Yes, that's the idea.
Also, since you're not using it before, you can declare ss after reading the line.
 
Okay. Thanks, btw i'm curious because it seems to be true, in c++ do you have to declare functions used by a current function ABOVE the current function?
 
Yes, you need to declare them before.
You know the difference between declaration and definition, right?
 
no :( if i do i don't realize it
 
void f(); is only a declaration. void f() { /* blah */ } is both a declaration and a definition.
You only need the function declarations before.
 
oh okay. RIIIGHT i forgot that back in the day when i was learning c++ i was told to do declarations at the top
<,<
i know that's the way it works for headers, but i forgot you could do that for a driver/.cpp
 
4:54 AM
There's a FAQ about it, if you want to read more:
43
Q: What is the difference between a definition and a declaration?

MaciekAs title says, the meaning of both eludes me.

Are there some Firefox magicks I can use to force opening a file in a tab instead of downloading it?
 
5:09 AM
Argh, where are the days that 4 hrs our sleep seemed to suffice.
 
@StackedCrooked that could be a song title?
 
@AlfPSteinbach Not that I know, but perhaps I could write a song about it.
Never mind that. I don't write songs.
 
cpx
5:25 AM
I've heard some people loosely use the term declaration for e.g this int value; when its actually a definition or declare and define value as an integer.
 
Note that a definition is also a declaration, so this isn't technically incorrect.
 
cpx
but in spec it says "A declaration is a definition..."
 
Other way around.
 
In school we referred to function declarations as prototypes.
 
5:44 AM
Hey, suppose I have a struct like this: typedef struct FooBar { int a,b,c; } foobar;
I wanted to have it inside another struct, but access .a .b .c members "directly"... Let me explain with code:
typedef struct Something {
    int something;
    FooBar fb;
} Something;
Something some;
I want to access some.a, instead of some.fb.a
Is there any way to achieve that?
 
Why all the typedefs? Are you writing C?
 
yep
To be precise, C for AVR microcontroller, but it's just plain old C.
 
It's not doable.
 
got an idea... Ugly trick using #define… I can put #define struct_contents int a,b,c;, and then put that macro inside both FooBar and Something. Ugly, I know, but I don't see other way.
 
Err..
What's wrong with int something; int a, b, c;?
 
5:53 AM
It's because int a,b,c; are actually more than just 3 integers.
 
Probably not recommended, but in C++ you could inherit FooBar.
 
@StackedCrooked You bring a good point.
C1x allows struct Something { struct FooBar; }; IIRC.
 
FooBar would actually have an unsigned char, followed by XYZVector (another struct), followed by an array of 4 XYZVector elements.
 
Other than macro tricks, I don't think it's doable.
 
@DenilsonSá is this something you really need or is it simply about syntactic convenience. If it's the latter then you could write a few inline functions instead.
 
5:58 AM
syntactic convenience.
Well, I guess I will "rewrite" all access to a,b,c to use that intermediate struct name.
 
Can't find a reference in the C1x draft-thingy, I'll just assume it's not in the language.
 
6:21 AM
Well, thank you guys. :)
 
6:39 AM
room topic changed to Lounge<C++>: Days without Singleton incidence: 2 [c++] [c++11] [c++-faq]
 
> error: converting to execution character set: Invalid or incomplete multibyte or wide character
Bad GCC!
 
@LucDanton Actually the bugs in gcc for detecting invalid sequences, are what allows simple beginner's Windows programs (encoded in Windows ANSI) to compile and work. g++ treats the source as UTF-8, but doesn't react to the invalid sequences. And thus they are just passed on. But it's a problem in wide string literals.
 
@AlfPSteinbach That's exactly what I'm testing. According to the documentation though, GCC is supposed to pick up the correct encoding for the source file from the locale. So first I'm investigating if I'm doing it right.
 
I was happy when g++ finally started accepting a BOM at start of file. Then it was finally possible to write "international" code that would compile with both g++ and msvc. Previously, g++ choked on the BOM while msvc required it, which was hopeless.
 
$ ./test | hexdump -C
00000000  3f 3f 3f 3f 0a 3f 3f 3f  3f 72 3f 3f 3f 3f 3f 3f  |????.????r??????|
00000010  3f 3f 3f 3f 3f 3f                                 |??????|
00000016
I like that some of the output isn't just 3f.
iconv can translate the literal from one encoding to the other just right, yet GCC does somethin wrong. Interesting.
 
7:05 AM
$ readelf -R .rodata test

Hex dump of section '.rodata':
  0x004020e8 01000200 00000000 00000000 00000000 ................
  0x004020f8 fffe0000 48000000 e9000000 6c000000 ....H.......l...
  0x00402108 6c000000 6f000000 2c000000 20000000 l...o...,... ...
  0x00402118 57000000 6f000000 72000000 6c000000 W...o...r...l...
  0x00402128 64000000 e7000000 e7000000 e7000000 d...............
Apparently the 'conversion' GCC used was ignoring any non-ASCII character?
 
uh, can you post the source code, and explain the problem?
i just note a missing "e"
 
#include <iostream>

int
main()
{
    const wchar_t text[] = { L"Héllo, World!\n" };
    std::wcout << text;
}
That source file is encoded in Latin-1 itself.
 
wcout used to be missing in Windows g++
i guess they implemented it now then
 
(I'm not on Windows.)
 
oh
i have only used g++ in Windows
but I think it will always treat the source file as UTF-8. try that.
 
7:08 AM
I can whip out the cross-compiler though.
 
btw. you don't need them curly braces
 
@AlfPSteinbach Supposedly it picks the encoding from the locale. Since that didn't seem to work, I explicitly directed GCC to handle the source as latin-1.
@AlfPSteinbach But I like curly braces.
 
i think it may still treat it as UTF-8
 
The 'conversion' it did was padding with zeroes actually.
 
all those "trojan" detections on my machine, all referring to [a.exe], was apparently about the example programs for the addition I wrote to Fred Overflow's array FAQ here
@LucDanton Latin 1 is a subset of Unicode, so if it did treat the source as Latin 1, then it should convert by simply padding
 
7:13 AM
Let's try the reverse, source is in UTF-8, execution sets are something non-unicode.
@AlfPSteinbach Good point. I get an ? when running the program in an UTF-8 terminal though.
$ ./test
H?llo, World!
So perhaps my font can't display e9? Weird.
 
maybe you're getting Latin 1 output. wcout converts to the narrow character set. and if g++ treats source as latin 1, then maybe it yields output as latin 1
 
I set it to UTF-32 wide execution set.
Actually I have to check that wcout works even before tinkering without the locales :(
Aaaaand it doesn't.
 
I'm confused, apparently I can't use UTF-32 in my terminal.
I wasn't aware std::wcout was that useless on Linux heh.
Can't pipe the output into iconv, I get iconv: illegal input sequence at position 0.
So I think GCC does the conversions okay (using iconv), but that the runtime is not doing something right (since I easily get 3f's everywhere in my output). I'm guessing that since wchar_t is 4 bytes here anything that's not UTF-32 will not be ouput correctly at runtime.
 
7:30 AM
@LucDanton Did you tell iconv which encoding it was receiving? (see -f parameter)
According to the manpage, if none is passed, it uses the current locale.
 
@DenilsonSá Yes.
 
Maybe different byte order?
 
Same results.
 
Just trying to clear the most obvious mistakes, as sometimes they are the most time-consuming to track down! ;)
 
No problem with that.
The string is correctly stored as UTF-32 in the binary but what's output is not UTF-32.
 
7:36 AM
@AlfPSteinbach Actually, ASCII is a subset of Unicode, but Latin1 isn't.
 
Alright, setting the locale globally to std::locale("") restores sanity. Makes sense.
std::wcout results in UTF-8 output in the terminal. Not bad!
 
@DenilsonSá ASCII is a subset of Latin 1. And Latin 1 is a subset of Unicode. The first 256 code points of Unicode are Latin 1.
 
Time to reward myself by buying fresh bread.
 
@AlfPSteinbach Okay, if you talk about codepoints… But Latin1 is not a subset of UTF-8 nor UTF-16 nor UTF-32. (but you never mentioned them, you just mentioned "Unicode") :)
 
@DenilsonSá The subset relationships reflect what parts of the world were considered by programmers: ASCII = US of A, then Latin 1 = Western countries (US + politically Western Europe), then Unicode = World
@DenilsonSá For the timeline we're talking 1967 (US of A), 1985 (Western world) and 1991 or thereabouts (World). 1991 was also the year when the US convinced the United Nations general assembly to revoke the old resolution that Israel is an apartheid country. This in order to bring Israel to negotiating table in Portugal, which of course failed (but Israel got a lot of monetary compensation for having so expertly wagged the dog).
More coffee...
@DenilsonSá Then, about UTF-16 and UTF-32, my point was that Latin 1 encoded text is converted to UTF-16 simply by replacing each byte v with 0v or v0, and likewise for UTF-32. In that sense, talking about encoding values, Latin 1 is a subset also of these encodings.
@DenilsonSá That encoding subset relationship was by design. Original 16-bit Unicode just extended Latin 1. And UTF-16 restricted to the Basic Multilingual Plane ~= original 16-bit Unicode (which we now call UCS-2).
 
7:58 AM
Yes, you're right. Maybe now I need some coffee. Actually, some food.
 
sbi
8:12 AM
It looks like the C guys again were faster than we were. Look at the last edit here, and its date.
 
8:31 AM
@sbi ?
 
sbi
@AlfPSteinbach !
 
I reserve my right to be downright stupid. What did you mean?
I mean I looked at it and it's a question about why C warns about valid C++ code. That's because it's not so valid in C. Right?
 
sbi
@AlfPSteinbach The last edit added the tag. In 2008. That's two years before we had the idea of crating an FAQ.
 
oh
but don't crate the faq
 
sbi
Indeed. Oh.
 
8:34 AM
it's fine as it is
 
sbi
@AlfPSteinbach According to my dictionary, "crate" is a noun.
 
Crates and barrels. The staples of an FPS.
 
Do you bring a gun to Crate And Barrel?
 
So... In C people shoot themselves on the foot... If instead they shoot the crate, they would find a c-faq inside...
 
9:22 AM
morning all
here's a challenge, without using a compiler, what does this print?
#include <stdio.h>
int main() {
  int x[5];
  printf("%p\n", x);
  printf("%p\n", x+1);
  printf("%p\n", &x);
  printf("%p\n", &x+1);
  return 0;
}
 
Supposing x is allocated at 0x1000 and sizeof(int) == 4, it should print 0x1000, 0x1004, 0x1000, 0x1014
 
Nice one :)
 
An array is not a pointer ™
6
 
Yes, that was the tricky bit about this question
not sure I get why the last one is 0x1014 and not 0x1004??
 
When you take the address of the array and add 1, the language treats it as an array of arrays.
 
9:29 AM
oh so it takes the sizeof the whole array?
 
I.e., you've just created a virtual 2-dimensional array of extent 1 in the second dimension, and gotten its 1-past-the-end pointer.
 
cpx
@Potatoswatter so, is it valid to have a pointer pointing one past the array?
 
Yes, 1-past-the-end is always valid. You can add one to any dereferenceable pointer.
 
10:17 AM
@Potatoswatter x+1 and &x+1 shouldn't be same? but they are different , how?
 
@MrAnubis no. x+1 is the same as (&x[0])+1, pointer to the first element, plus 1, yielding pointer to the second element. &x+1 means, pointer to the array, plus 1, yielding pointer to an array following this one.
 
@AlfPSteinbach aah , forgot that &x doesn't decays to pointer
@AlfPSteinbach Thanks
@AlfPSteinbach i remember there are three cases when array name in expression doesn't decays to pointer , when used with & and other two?
@vivek aur vivek ji kya chal raha hai?
 
Binding to a reference and using sizeof, perhaps?
 
@LucDanton yes , thanks :)
 
@MrAnubis :) अच्छा हूँ | तुम बताओ |
 
10:28 AM
Is it frowned upon to cross-post to comp.std.c++ and comp.lang.c++.moderated?
 
yes
 
@vivek cool , yaha pe sab mast hai
 
@vivek Is that an answer to my question? A serious one?
 
@Potatoswatter yes
 
Well, I hope the moderators don't reject my submission. I have terrible luck with them.
 
10:31 AM
I remember I read this somewhere in the faq
 
They drop so many posts that it just seems like good insurance.
For example this: groups.google.com/group/comp.std.c++/browse_frm/thread/… — I posted a message asking about wide raw literals, then submitted a reply to myself later in the day. They only posted the second message, which makes no sense with no context.
It's like they wanted to punish me for changing my mind, but since they did post the one which doesn't make sense on its own, everyone suffers.
 
I have never posted to any of those groups, only subscribed
 
It seems to be the only way to go for defect reports.
Ah, the FAQ says that crossposted articles take longer to appear due to more work for moderators.
I guess that means I shot myself in the foot. Instead of getting insurance that it will be posted more quickly to one group, it will be only approved by the consensus of moderators from both groups.
 
@Potatoswatter no, we support that. any article that is on-topic in comp.std.c++ is also on-topic in comp.lang.c++.moderated. however, some years ago we stopped supporting general cross-posting, because it involved much work and took long time to process articles.
 
FAQ are a must read, if it's a C++ related group :)
 
10:40 AM
What's the alternative called? Multiposting?
 
@LucDanton yes. don't, please
 
@AlfPSteinbach Oh, cool :) . You're a mod for c.l.c.m?
 
yes he is
 
@Potatoswatter comp.std.c++ doesn't do defect reports any more. look at the faq at the comeau site for alternatives.
@Potatoswatter yes
 
@AlfPSteinbach According to comeaucomputing.com/csc/faq.html#B15 Usenet is still the preferred procedure…
 
10:43 AM
@vivek but that doesn't mean i'm moderate! ;-)
@Potatoswatter sorry, i thought it was updated.
 
But it also says invalid submissions will be returned to the sender with an explanation, which is just funny to me.
@AlfPSteinbach So, what's the new preferred way? Mail directly to the DR list owner?
 
@Potatoswatter I don't know. The Comeau faq says mail to Francis Glassborow as last resort. I don't know. James Kanze is here on SO and he is a committee member. Maybe ask him?
Or I can check
 
LOL, thanks. Anyway on second thought I should just post the content of this Usenet message to SO. It's not a DR, but it possibly could be rephrased as one.
 
@Potatoswatter I just asked James Dennet on Facebook. That must surely give fast response. He he.
 
sbi
@AlfPSteinbach James is a committee member? I thought he was, like, 15 years ago. I'm quite sure he was not for some time in between. I didn't know he is again now.
 
10:50 AM
0
Q: Direct vs uniform initialization in std::allocator

Potatoswatter This question has also been submitted to Usenet, where it is more appropriate, but this is a larger and more reliable forum. std::allocator::construct is defined to forward its argument parameter pack to using parentheses, a.k.a. direct-initialization. If it used braces, a.k.a. uniform init...

 
@sbi James (Kanze) fixed the <ostream> include bludner, that's the most recent committee activity I know he's engaged in. And it was not so long ago.
 
sbi
@AlfPSteinbach Yeah, my "news" regarding this is from >10 years ago. So he has joined the committee again. Good.
What is "the <ostream> include blunder", @Alf?
 
11:10 AM
@sbi C++98 formally required you to include <ostream> if you wanted to use e.g. endl. However, all the (non-normative) examples in the standard just included <iostream>, and that's how things worked also in practice. So, for C++11 added wording that guarantees that <iostream> drags in <ostream>, and I think also <istream>, so that you can just include <iostream> and code away...
 
sbi
@AlfPSteinbach Ah, I see. Yes, this makes sense.
 
11:21 AM
@Potatoswatter I think I'll give uniform initialization a try with that SFINAE trick for generic contexts.
 
@LucDanton Cool, you mean hack your copy of the standard library?
 
No, for when I do construct objects in my code.
I noticed how broken uniform initialization is when passing std::vector blew up in my face, I like your idea however.
 
Ah. That will get confusing when you switch between standard and custom make templates, no?
 
e.g. I have a make_unique that does a new T(std::forward<U>(u)...).
And there's no std::make_unique :)
 
Not return std::unique_ptr< T >( std::forward< U >( u ) ... );?
 
11:25 AM
Need to new somewhere.
With your suggestion I'd need to make_unique(new T(expr)). That's not desirable for exception safety.
 
I forgot whether the unique_ptr constructor did forwarding to new internally.
 
Nah, they accept pointers and allocators and deleters.
 
Anyway… what does your make_unique accomplish if it only forwards to new but doesn't make a unique_ptr?
 
No, no it does return an std::unique_ptr. But the T creation happens with a new expression.
 
Oh, alright :)
 
11:28 AM
The std::unique_ptr is created using direct initialization (probably? I don't remember) and that's not relevant.
I also use emplace_back here and there. I can add overloads that do uniform initialization around that.
 
sbi
room topic changed to Lounge<C++>: An array is not a pointer ™. [c++] [c++11] [c++-faq]
Going too long with the same tagline for the room makes me itchy. :)
 
It's nice that we went 2 days without a singleton incident… but 1 would have been funnier.
Man do I regret moving to the third world to save on rent. I'm stuck at this internet cafe for 4 hours because I need to download a copy of Ubuntu.
Hey, here's a neat trick: I want a list of objects that can delete themselves from the list. But it's performance-critical. Need an intrusive list, right?
Instead, I should be able to use a forward_list where each object keeps an iterator to the preceding list item. So it's only semi-intrusive and uses only standard components.
 
Needs the list as well as the iterator though.
 
Yes, this is true, at least if the removal needs to happen in the destructor. But for a multithreaded program, you can't get around that even with an intrusive list.
Hmm, since there's no good reason for std::forward_list::erase to need its implicit argument, can it legally be declared static?
 
sbi
11:48 AM
@Potatoswatter Where did you move to? (And where from?)
 
@sbi From Arizona to Tarlac, Philippines
That must make me the ultimate snowbird. And I love snow. Go figure.
I wanna go on a road trip to Alaska when I get back. Screw the expenses.
 
Hi,
@LucDanton I finally got it working.. the hard way lol
 

« first day (368 days earlier)      last day (4570 days later) »