« first day (512 days earlier)      last day (4438 days later) » 

12:00 PM
Does anyone here know of a very lightweight library for cross-platform OpenGL windows and keyboard event handling? Something like lwjgl but for C++.
 
By using make_shared however only one allocation takes place which means that both reference count and object live in the same piece of memory.
So if you have a boost::weak_ptr<T> then it must still have access to the reference count even though the object might have been destructed already.
Does that make sense?
This only appears when boost::weak_ptr<T> is involved.
Otherwise the big memory block will always be deallocated when the last boost::shared_ptr<T> expires, so right after the T is destructed.
 
@daknok_t SFML – seriously rocks
 
@KonradRudolph I'll check it out.
 
@daknokt The developers of SFML must have read my “fuck pointers” slides ;)
 
Nice.
 
12:11 PM
@LucDanton Yes, it does. I think I had a misconception before … just to clarify this: weak_ptr has always access to the reference counting block of a shared_ptr? I.e. even when not creating a resource with make_shared, the refcount block is preserved until all weak_ptrs die, even if no shared_ptr exists any more?
 
@KonradRudolph That is the case with boost::weak_ptr, yes.
 
@Luc So not with std::weak_ptr?
 
@KonradRudolph The control block has to be kept alive in order for weak_ptr to work.
Otherwise, how could it possibly know whether or not the object had already been destroyed?
 
There's no requirement on the implementation. It could go the way of boost::weak_ptr or do something else, like put a list of all std::weak_ptr subscribers inside the control block and then the last std::shared_ptr could somehow disable the std::weak_ptr subscribers when it leaves. Making that work in a sensible manner when taking into account thread-safety is really iffy though.
All in all it's an insane scheme but it's not disallowed.
@FredOverflow Black implementation magic of course.
 
oh my
shared_ptr does involve quite a lot of trade-offs
 
12:18 PM
Yes, that's why it's almost impossible to design and implement a perfect smart pointer yourself :)
 
std::unique_ptr is very, very nice.
 
@LucDanton Yup, it’s a little gem
 
@KonradRudolph STL lays down Microsoft's implementation of std::shared_ptr in this recent talk, if you're interested.
 
@FredOverflow I’ve already downloaded this talk, I just need to find time to watch it
 
12:28 PM
@KonradRudolph millions of linker errors xD
Screw it, I'm gonna write it myself (TM).
 
Hello, Tony.
 
now when you store a type int and put "5" in it, is this unicode encoded or ASCII encoded?
I'd guess the answer is no
 
How and where do you store a type, and how do strings come into it?
 
a type is stored in memory
 
12:32 PM
@TonyTheLion the code depends on the platform
 
@TonyTheLion Is it?
 
'5' is always encoded, no matter if you place it in an int variable or a char variable.
 
but would the char type "know" the value of the char '5' like the int type does?
 
@TonyTheLion Are you talking metadata?
 
@TonyTheLion Of course; there is no such thing as a character. Everything is encoded as zeros and ones.
On ASCII systems, '5' is just another way of saying 53, if you will.
0
A: C++ | main function error | beginners

FredOverflowchar a; while (a!='q') You are comparing an uninitialized variable with the letter q. Reading from an uninitialized variable invokes undefined behavior. If you're unlucky, a!='q' might be false. Change char a; to char a = 0; (or any other non-q value) or replace the while loop with a do-while l...

yay UB
 
12:39 PM
@FredOverflow ah, so no matter in what type you're storing "5", it's always encoded, whether it be int or char
 
@TonyTheLion yes
 
@FredOverflow So why do we need to cast? Especially in C#
 
char is actually described by the standard as a numeric type if I'm not mistaken. Let me check.
@LewsTherin Because char is too small to hold every possible int.
 
until yesterday, I thought char was only ever supposed to store letters of the alphabet (a-z), which is why I was always confused when people used it to store other data in it. But a character as I learned yesterday can be any symbol on your keyboard or in the UNICODE or ASCII char set, which is numbers too. But now, what is the difference between storing a digit in a int type and in a chartype?
besides that char can store any character, and int only digits
 
12:43 PM
I think you can store any type of data in a char.. as long as it is exactly one byte or less
 
Space, and similarly the possible range of values for each type.
 
hahah, interesting, of course!
int = 4 bytes (32bits) and char = 1 byte (8bits)
 
On some implementations.
 
Yeah
 
yea that's a given
 
12:44 PM
Yep, char is an integral type, just like int.
 
Oh yeah, another difference between char and int is signedness.
 
That's why you can use char in a switch statement.
Use a string and the compiler gives you the finger.
 
@TonyTheLion A charset is just a mapping from numbers to symbols. What is stored is the number (because that's the only thing a computer can store), not the symbol.
 
@FredOverflow So if I did char a = (char)256; is that compile time error then?
 
@LewsTherin in what language?
 
12:47 PM
C/C++/C#
 
It's a compile-time error in C#, and it will initialize a to 0 in C and C++, provided char has 8 bits.
Oh wait, char is wider in C#.
It will initialize a to 256 in C#.
 
Yeah it is 2bytes
 
exactly
 
C\C++ should give a warning at least. Will test it when I come back.
 
If you look at the Java spec, char is just a numeric type that can store numbers between 0 and 65535.
 
12:49 PM
Talk soon guys.
 
@LewsTherin If you want warnings, you shouldn't use C-style casts.
 
@FredOverflow char (aka plain char) is not unsigned char.
 
@LucDanton so?
 
Only unsigned types have modular arithmetic, signed types have UB.
 
12:51 PM
I'm not sure what happens if casting a large value into a smaller data type. Let me check the spec.
 
I don't remember the size (and range of values) guarantees for char types nor where to look either.
In any case the question can be phrased in terms of "What happens if I do char c = (char)(CHAR_MAX + 1);".
 
4.7 Integral conversions [conv.integral] §3
> If the destination type is signed, the value is unchanged if it can be represented in the destination type (and bit-field width); otherwise, the value is implementation-defined.
@LucDanton so no UB here
 
How bizarre.
 
mapping 256 to 0 seems feasible.
 
This means that short s = /* ... */; s += 1; is never UB.
And of course int i = /* ... */; i += 1; can be.
 
12:58 PM
right, because you get an implicit conversion to int first, and an implicit conversion to short second.
On the other hand, if sizeof(short) == sizeof(int), you get UB.
@Johannes No templates to see here, move along ;)
 
Ugh, reddit comment threads become chaotic very fast :(
no wonder Jeff was so dead set against hierarchical comments on SO
but they could be implemented much better
 
hmm
why would int i = ...; i += 1; be UB?
or do you mean because of "..." being ub?
but why doesn't the same apply to the short version?
ah i see because "i" could be INT_MAX
but why does this not apply to the short version again?
 
7 mins ago, by FredOverflow
> If the destination type is signed, the value is unchanged if it can be represented in the destination type (and bit-field width); otherwise, the value is implementation-defined.
 
hm i'm unsure whether the intention is actually that the stated equivalence "s = s + 1" is that actually the right hand side is converted to short again
 
Not much of an equivalence!
 
1:03 PM
because... why would it be UB for int and not for short.. doesn't make sense!
and int i = ...; i += 1L; would be not UB again?
lol
 
8 mins ago, by Luc Danton
How bizarre.
 
lol
and did you know that char is neither signed nor unsigned
 
yes and no
 
so the description in 4.7do not apply to char
 
char, signed char and unsigned char are three distinct types
 
1:07 PM
yes, but char is also not an unsigned nor an signed integer type
 
but char either has a sign or it doesn't, right?
 
Wow, the slides sure proved controversial on reddit
> 20 up votes 17 down votes
 
@FredOverflow it is neither an unsigned nor a signed integer type
so it is UB to say char x = 256;
 
> The standard signed integer types and standard unsigned integer types are collectively called the standard integer types, [...]
Welp.
 
char and bool are hence not standard integer types, if that quote is correct
 
1:09 PM
@JohannesSchaublitb What about this?
 
@FredOverflow those trait classes do not determine whether a type is a signed or unsigned integer type
 
> In any particular implementation, a plain char object can take on either the same values as a signed char or an unsigned char; which one is implementation-defined.
Hm, so what you're saying is that even if char consists of the same values as signed char, the conversion rules are still different? That would be really weird. But hey, this is C++ after all.
@JohannesSchaublitb So what do they determine? Oh wait, I didn't see the "integer" part.
 
different things
whether -1 converted to T is -1 and such
 
The things we get for plain char out of clause 3 is: it can hold any value of the basic character set, that value is the same as that of the same character literal, it's a character type, it's implementation-defined whether it can hold negative values, and it hold the same values as either signed char or unsigned char.
That's not too much tbh.
 
I don't think I'll ever write a mission-critical system in C++. I don't even know the basic type conversion rules :)
 
1:18 PM
inofficially bool can represent values 0 and 1. but the committee did not feel like fixing the bug in the spec that my defect report pointed out
too bad, another 20 years of not having a normative reference that says that bool can represent 0 and 1 :)
or another 20 years of nonconforming compilers that accept narrowing conversions like bool x = { 1 };
 
@JohannesSchaublitb har har :)
 
Extra extra: Increase your bool range from [0, 1] to [0, 255] with the help of undefined behavior!
 
    template< class Type >
    struct Ownership { using Ptr = std::unique_ptr<Type>; };
^ Is this valid C++11 syntax?
I don't have good compiler to test with, and the standard is a bit long
 
@CheersandhthAlf yes this is valid
 
2:07 PM
is there nothing like a binary tree container in the standard now?
 
@bamboon Binary tree for what?
The standard isn’t a repository of specific data structures, it provides specific-use data structures
 
@KonradRudolph you mean what I need it for?
 
@bamboon Yes. There are thousands of different uses of trees, some of them are covered by the standard library
 
@bamboon You mean like std::map?
 
no, more like a binary search tree
 
2:15 PM
... ... std::map is an R/B tree
log(N) insert, delete, find?
 
@bamboon a binary search tree is an implementation detail. The standard library doesn’t expose interfaces to implementation details
std::map and std::set are implemented in terms of a binary search tree
More precisely, they guarantee performance characteristics compatible with a binary search tree, everything else is up to specific vendors.
But in practice this means that all (?) implementations use an red-black tree
 
a binary search tree can be explicit, with left() and right() members
 
which, by the way, is sub-optimal. Modern processors prefer B trees due to improved cache locality
 
and with depth(), etc..
 
well yeah interesting stuff, I am looking for an explicit version like johannes is suggesting
 
2:22 PM
no, the Standard would never expose a container like that, realistically
 
well yeah, didn't find one, that is why asked. anyway thanks guys
 
@bamboon please tell me you found this question on the subject: stackoverflow.com/q/205945/256138
there's like ten links in the answers to tree implementations in C++
New GCC 4.7 and LLVM/Clang builds from the oven!
Please use the Clang build with the GCC 4.6.4 built libstdc++ for best results. GCC 4.7's libstdc++ uses incompatible atomics which Clang chokes on.
 
@rubenvb thanks for the link, to be honest I didn't search first because I didn't think the question was not even SO-question worthy
 
@bamboon why not? It's a straight up coding question: anyone know a good binary tree implementation in C++?
Great, Skydrive is down...
 
2:50 PM
there is an opensource B* tree implementation. iirc it is quite good
 
aarrrgh, more clang initializer list badness.
 
something miraculous just happened to me
Windows Help was actually helpful
my universe, it's just turned upside down
 
lol
i thought F1 starts up the racing simulator
 
@DeadMG you sure you didn't just fall on your head and read the Windows Help message upside down and backwards?
 
@rubenvb But, but, it's advice worked!
 
2:53 PM
@DeadMG I think you're drunk.
...at the very least
 
haha
I've only been awake three hours at most and haven't had a sip of alcohol
 
sleep deprivement can erase short-term memory
...which makes so little sense now I reread it...
 
lol
 
The sucks is on you, Clang! ideone.com/4AzSF
 
why?
I also notice that code is missing many of the configurations for many of the toolchains- especially e.g. static and dynamic library extensions
 
3:01 PM
because they need an LLVM toolchain
 
It's a reduced incomplete code example, but it should compile.
basterdz
It's WIP code I lay to rest sometime ago
 
oh, two new shiny badges
 
Now someone fix that.
 
3:17 PM
@JohannesSchaublitb Could you check if compile times are better with my new build?
 
currently i'm busy :(
 
np, just wondered. I don't think debug link times will have changed on a 1GB RAM machine though. Maybe the compiler might be a bit better...
 
3:37 PM
Arrgh Arch Y U break GCC with PPL update? bugs.archlinux.org/…
Thankfully, pacman stores previous versions of packages. All is well :)
 
argh, people really don’t like the suggestion not to use pointers :(
 
pointers are teh kewl
 
’pparently so
 
@KonradRudolph It's very hard to convince the void* guys to program in modern C++.
 
even harder to convince your mother! O_o
 
3:52 PM
At least I don't have to convice her to stay away from void*s in the first place.
 
heh
true true
hmmm
wonder if I can hardware instance from more than one instance stream at once in Direct3D9?
 
4:05 PM
0
A: C++11: Best way to implement decorator with rvalue references

XeoYou seem to have a misconception of what moving really means: A move is just a better copy. As such, a move is never worse than a copy, and if the type contains external data, it is always faster (assuming a sane move constructor).

see comments
 
@JohannesSchaublitb Building Clang with Clang on Windows is a bust. CMake sucks and the configure script wants to use -Wcovered-switch-default. Any ideas?
 
hmm
CXXFLAGS=-Wno-covered-switch-default ?
 
@JohannesSchaublitb clang's cc1 complains it doesn't recognize the flag :( I'll try meddling with the CXXFLAGS
the stupid configure script does this: COVERED_SWITCH_DEFAULT=`$CXX -Werror -Wcovered-switch-default -fsyntax-only -xc /dev/null 2>/dev/null && echo -Wcovered-switch-default`
which shouldn't echo if CXX doesn't know it. Yet this fails miserably. Ugh.
Well, CXXFLAGS="" worked
 
4:22 PM
ok
Ubuntu, y u no accept my account with no password?
 
Baby's first stack overflow: void handle(int){std::abort();} int main() { std::signal(SIG_ABRT, handle); std::abort(); }
 
user406009
Wouldn't that just abort? I swore signal resets itself.
 
user406009
"In the original Unix systems, when a handler that was established using
signal() was invoked by the delivery of a signal, the disposition of
the signal would be reset to SIG_DFL, and the system did not block
delivery of further instances of the signal."
 
user406009
And from cppreference: "When signal handler is set to a function and a signal occurs, it is implementation defined whether std::signal(sig, SIG_DFL) will be executed immediately before the start of signal handler. Also, the implementation can prevent some implementation-defined set af signals from occurring while the signal handler runs."
 
@DeadMG Cause that's Unix for you...
 
4:33 PM
wait
there's std::signal now?
 
hi, can somebody tell me what softwares were written in c# ? i've googled - with no success. Yea , i'm asking that,, because everybod recommends c# instead of c++, but i don't see any powerful softwares written in c# , just visual studio.
 
how is that going to work in Windows?
@ddacot Oh, yeah. Let me just dig out that list of software written in C# that I keep handy for just such an occassion. Oh, wait.
 
@EthanSteinberg Oh, OK, it's implementation defined...
 
@DeadMG there's <csignal>, doesn't mean much IMHO.
 
@DeadMG ok, i'm waiting.
 
4:36 PM
@ddacot I'm sorry, did you miss the gigantic sarcasm? Obviously nobody has anything like "A list of software written in C#".
 
user406009
Especially since all the good signal handling stuff is not in there.
 
user406009
signal() is a load of junk.
 
@DeadMG unfortunately yes, i missed your fking sarcasm , and yes, i didn't ask to give me a list of softwares, i ask to give me examples.
 
well, that's really not something that any of us would keep around
try the C# room?
 
@DeadMG MSVS11 Beta has a csignal and signal.h file. I have no clue what could be missing though
MSVS10 has the exact same files..
 
4:40 PM
@DeadMG nobody is active.
 
oh, I see
 
Where's the previous room line/description when you need it
 
so... that makes it more likely that we'll have the answer, then?
 
user406009
Wouldn't monodeveelop be written in C#?
 
hello
 
user406009
4:41 PM
The creators of the IDE would probably at the very least like C# and want to use it.
 
@rubenvb signal and raise are in both the C and the C++ standard library.
 
what the hell is gedit?
 
user406009
A better notepad. Sort of halfway betwwen notepad and notepad++.
 
so why the hell did the nVidia drivers I downloaded open in that?
 
@EthanSteinberg isn't gedit with plugins equivalent to notepad++?
 
user406009
4:49 PM
@rubenvb Not quite, notepad++ still has more features. gedit can get close though, thus it is like a halfway point.
 
@DeadMG because it's set as the default text editor and the NVIDIA drivers opened the license file? Why are you downloading custom NVIDIA drivers on Ubuntu?
 
@rubenvb I'm not downloading any custom drivers. I got them from the nVidia website.
 
@DeadMG you should apt-get install nvidia-driver, not install them from the NVIDIA site.
 
user406009
Why not just download the drivers through the package manager or ubuntu's driver utilities?
 
or open the Hardware Drivers utility Ubuntu has.
 
user406009
4:51 PM
Get into System Settings - Additional Drivers
 
Windows != Ubuntu, it works differently.
 
@rubenvb differently != much worse
 
posted on March 11, 2012 by Alf P. Steinbach

Part I of III: The LSP and value assignment. Abstract:Liskov’s principle of substitution, a principle of generally good class design for polymorphism, strongly implies the slicing behavior of C++ value assignment. Destination value slicing can cause a partial assignment, which … Continue reading →

 
so basically, if I want to get drivers from nVidia, I have to go through a shitbunch of third party programs?
 
@DeadMG wut?
 
4:52 PM
totally intuitive and logical...
 
No, you go through the OS.
 
user406009
I actually like ubuntu's package management system. Everything is in one place and gets autoupdated.
 
@rubenvb Which is neither me nor nVidia, so third party.
 
@EthanSteinberg That's a valid statement for every decent Linux distro
@DeadMG get used to it. Everything on Linux is third party
 
I'd really rather not get used to it
 
4:55 PM
Why are you installing Ubuntu anyways?
 
"Ask nVidia" seems like a perfectly logical solution to the problem "Need drivers from nVidia"
 
@DeadMG on Windows: yes, for most Linux distro's: no.
sheesh
 
no
 
the OS is not factored into that logic
if I want food, I don't ask Chrome to ask Tesco to get it for me
I go to Tesco
 
4:56 PM
@DeadMG your logic is flawed.
If you need drivers for the OS, you ask the OS.
 
no
there is no need whatsoever for Ubuntu to care
 
You can even ask Windows for drivers
 
user406009
Think of the logic like this: The OS manages my computer. I want more programs for my computer. I tell my OS to get more software. Perfect sense.
 
it often works
 
you ask the OS, the OS asks the manufacturer
 
4:57 PM
@EthanSteinberg I manage my computer. The OS does what I tell it to. If I can serve a function on my own, I do not expect the OS to get in the way.
 
experienced ppl may shortcut it and ask the manufacturer themselfs
 
This is one of the reasons Linux adoption sucks: people are stuck in their old habits, which aren't efficient
 
it's like UAC, except you can't turn it off
@rubenvb Because it's totally efficient to go through the OS instead of just doing it myself? I don't think so
 
user406009
You can bypass the package manager and install stuff yourself.
 
user406009
Good luck upgrading or uninstalling stuff though.
 
4:59 PM
@EthanSteinberg I'm trying. But apparently, Ubuntu thinks that for the ".run" extension, whatever that is, that nVidia gave me, the correct action is to open it in a text editor
 
which is arguably stupid. sudo apt-get install nvidia-drivers is a lot faster than compiling the NVIDIA driver modules yourself.
@DeadMG use a terminal
ffs
 
user406009
@DeadMG What is the first line of that Nvidia file?
 
@rubenvb Who said anything about compiling? nVidia compiles it. I just download it.
 
user406009
(Betting it's a shell script)
 
@DeadMG not on Linux. Kernel modules are compiled when you execute the *.run script
 
5:00 PM
@rubenvb Why? It's an executable file. It has an extension- the purpose of which is to tell the OS it's an executable file. So why can't the OS just damn execute it?
right
 
@DeadMG dude: sudo apt-get install nvidia-drivers
 
gee
I sure hope that for every other program I want to install, I can divine the magic string which indicates that program
 
apologies, it's nvidia-current
@DeadMG + Ubuntu == catastrophic failure.
 
@rubenvb See? You can't even get it right.
 
@DeadMG you can use your GUI package manager
every distro has different names for packages, I don't use Ubuntu.
 
5:02 PM
I did- it's called "Firefox" -> "www.nvidia.com"
 
ugh
good luck
sucks to be you
 
sucks to have to use Ubuntu
not least of which that virtual box won't give it my screen resolution so I'm stuck on 1280x1024 :(
 
i used archlinux before i switched to windows
 
@DeadMG If Linux does not behave the way you expect, you can always leave. Nobody forces you to use Linux.
 
@DeadMG You're installing NVIDIA drivers in Virtualbox? WTF man.
5
 
5:03 PM
lol
 
catastrophic failure was an understatement.
 
@rubenvb I have an nVidia GPU. Why wouldn't I want nVidia's drivers for it?
 
@DeadMG cause a VM doesn't have the NVIDIA GPU.
 
you need to install virtualbox guestadditions
 
as stated in the VirtualBox Manual. RTFM
 
5:04 PM
@FredOverflow Unfortunately, my brother is being a bitch about editing his Android images, and there are no useful tools for doing so on Windows- thanks very much for that one, Google.
@rubenvb It's a virtual operating system on my machine. My machine has an nVidia GPU.
 
@DeadMG RTFM
 
@bamboon I did that.
@rubenvb No.
 
@DeadMG then stop bitching in the C++ lounge
 
user interaction 101: The user is not going to waste their lives reading a hundred-page manual before attempting to use your program.
 
user406009
Then why don't you just use the provided for driver manager?(If you don't want to read the manual)
 
5:05 PM
emacs^^ ?
 
@DeadMG did you activate 3D acceleration in your vm settings?
 
VirtualBox does not appear to possess such a setting
 
@DeadMG What are "Android images" anyways?
 
@rubenvb They're like regular ISO files of the OS, except Google made their own format for some unknown reason.
and then declined to publish any useful tools to edit them for Windows
 
you mean ROMs?
 
5:07 PM
yes
 
@DeadMG it does, shut down the machine. click on display and there you will find it
 
@ScottW I don't even know what that is?
no
they're not executable, they're images, to be flashed
 
@ScottW not APKs, but ROMs containing the OS and system apps.
@DeadMG he wants to mod ROMs and can't figure out how to install Linux. Damn...
 
hey, I already installed Linux
not my fault it's an unusable piece of crap
 
the fact that you couldn't execute the NVIDIA installer script makes me doubt very much you installed the guest additions...
 
5:13 PM
you dont need to install the nvidia drivers anyway
 
it had a button saying "Active guest additions" and I clicked it and it said "Guest additions activated"
 
@DeadMG what had the button?
 
some popup crap
 
VBox or Ubuntu?
 
I would have ignored it if it didn't have "VIRTUALBOX" stamped on it
Ubuntu
 
5:13 PM
did you activate 3D acc now?
 
anyway, the screens are fine now, both of them rendering at the proper resolution
@bamboon yes
 
I'm just going to stop helping someone who can't find google.
cyall
 
@DeadMG and it didn't help?
 
help with what?
 
with your resolution problem?
 
5:15 PM
yeah, it seems to be fine now
 
perfect
 
Xeo
@Mysticial: You might get a few more upvotes on that subnormal float question, the news y-combinator picked it up.
 
Hello folks :)
 
5:43 PM
Hi!
Just pushed the work I did so far on my roguelike. Anyone up for some testing? I'd be especially interested to know if it works fine on Windows and Mac OS X. (Warning: it's really boring so far.)
 
I could test for Mac. However, I'm very sleepy at the moment :)
 
give me a minute to eat what I'm eating and I'll DL it
 
@CatPlusPlus I do?
 
Holy shit, WTF? Why did I just get so much rep?
@Xeo Oh... ic...
 
@RMartinhoFernandes linky?
 
5:56 PM
You'll have to build it yourself, and that means installing the Haskell Platform.
 
yeah
that I just noticed
 

« first day (512 days earlier)      last day (4438 days later) »