« first day (496 days earlier)      last day (4451 days later) » 

10:00 PM
Wait, you do. You can't have multiple type constraints. My mind wondered into Haskell-land for a while.
 
lol
 
I was thinking of something like (ReadTexture & WriteTexture)* get_rw_texture();.
Meaning it returns a type which provides both interfaces.
The way to do it is indeed with MI.
 
well, it was fine when I had ReadWriteTexture : ReadTexture alone and didn't need WriteTexture
but the back buffer in Direct3D isn't a ReadTexture
it's just a writable surface
 
of course, since they're strict interfaces, then using virtual inheritance won't be a killer
 
10:03 PM
how do I use WGL_DRAW_TO_WINDOW_ARB if I don't have a context yet to load my functions?
 
it's just irritating to have to do
 
Yeah, I know the feeling.
 
@DeadMG This seems like a situation where concepts could help.
 
@TonyTheLion Where do you need that?
 
@StackedCrooked How so?
 
10:07 PM
@StackedCrooked Typeclasses!
 
derp:
 
7 mins ago, by R. Martinho Fernandes
Wait, you do. You can't have multiple type constraints. My mind wondered into Haskell-land for a while.
I called it!
 
@CatPlusPlus opengl.org/wiki/Creating_an_OpenGL_Context under "Proper Context Creation"
or just CTRL+F it on the page
 
(ReadTexture t, WriteTexture t) => t -> whatever
 
@RMartinhoFernandes heheh :)
 
10:08 PM
@TonyTheLion Eh, you can do with just PFD.
Anyway, you need to create a bootstrap context first, I told you.
 
ah ok
 
Readable and writable can be modeled as type constraints. I haven't thought further... :D
 
well, I could do something Teh Uglies and simply provide three separate implementation classes
but then I'd have to constantly dynamic_cast between them
 
create_boot_context and create_real_context.
 
@DeadMG But honestly, I would probably use a runtime solution like the bridge pattern, or a modern C++ solution like policy based class design.
 
10:10 PM
hmm, creating a map with a large number of elements is slow. Time to do 100000 lookups on a map with 10000000 elements: 172 ticks. Time to create said map: 30549 ticks. (That's 30+s)
 
You can put the pixel format selection again in create_real_context, if you really need to use that WGL extension.
 
I'd like to use templates, but there's just too much compile-time leakage
 
struct D3D9ReadWriteTexture : ReadWriteTexture { /* some duplication or boilerplate (composition+delegation) here :( */ };
 
@MooingDuck Surprised? It's O(log(n)) lookup and O(n) creation
 
In the past I've used bridges a lot. They always work. If you're willing accept the pointer indirection.
 
10:11 PM
@StackedCrooked I changed the clock iteration to 20 instead of 15 and it gave me much smoother output :D
 
@DeadMG creating and sorting a vector on the same data was 1597 ticks. I was shocked at the difference between them
 
@RMartinhoFernandes I've considered that. The problem is that when it comes to get the necessary elements out of the implementation class, I'd have to constantly check which derived class I was dealing with
 
@DeadMG It's O(n log n) creation.
 
I mean a context. You need a device context to create OpenGL context. Dunno if you can use DC with no window, but creating a window is one way to get DC.
 
@MooingDuck vector has O(log(n)) allocations, and it's a much faster sort too because it's contiguous
 
10:12 PM
Read that code, it works.
 
@RMartinhoFernandes Yeah, I just remembered that.
 
@RMartinhoFernandes typedef Texture<Read | Write, WinAPI::D3D9> D3D9ReadWriteTexture; Looks cooler :D
 
@DeadMG vector allocated to the right size from the get-go because I knew the size. I was just shocked at the 19x time difference. I didn't expect it to be quite that much. I expected 1.5 to 2x.
 
well
 
@StackedCrooked But exposes types it shouldn't on the API.
 
10:13 PM
@MooingDuck So O(1) allocation and and no copies, compared to O(n) allocations and O(n log n) construction time?
 
The WinAPI::D3D9 part needs to be erased. (I assume that was the reason to use inheritance in the first place)
 
@CatPlusPlus I created a window
and I got a DC
 
@RMartinhoFernandes Maybe you're right.
 
what I could do is make textures loaded from files writable, I guess
@RMartinhoFernandes Yep
 
@DeadMG the vector has to O(n log n) sort, with lots of copies
 
10:14 PM
@MooingDuck Swaps, actually.
 
@MooingDuck Swaps don't involve copies if the type is movable (or specializes swap).
 
but the memory is contiguous and you saved lots of allocations, and allocations are almost certainly way slower then copies or swaps.
not to mention the cache savings and repeated indirection savings for not needing the extra pointers that a node-based container does
 
Poco's approach to the file class: File.h File_WIN32.h File_WIN32.cpp
 
then I wouldn't need ReadTexture
 
@DeadMG I tried (and failed) to figure out how to use MSVC's other allocators for speed (or a custom one)
 
10:17 PM
@DeadMG Hmm, no read-only textures? That has a weird feel to it, but it seems it might work..
 
well
it's either that or multiple virtual inheritance
 
actually, I can't do that at all
 
@DeadMG I had some exposure to multiple virtual inheritance. It's messy stuff.
 
then I'd have to have them D3DPOOL_DEFAULT and copy them over and shit between device resets and ...
 
10:19 PM
MVI it is then...
 
I guess it's not that bad for a couple interface classes
 
1
Q: Using lambdas to do nested functions

Arcadio Alivio SinceroWhat's everybody's opinion on using lambdas to do nested functions in C++? For example, instead of this: static void prepare_eggs() { ... } static void prepare_ham() { ... } static void prepare_cheese() { ... } static fry_ingredients() { ... } void make_omlette() { prepare_e...

 
Private inheritance instead of composition of a pointer type eliminates the pointer indirection. I just realized that's quite a clever trick Poco did there.
It doesn't expose non-portable stuff either.
 
maybe I should just cut ReadWriteTexture and instead return std::pair<ReadTexture, WriteTexture>?
 
ideone.com/h474D Does it need anything else?
 
10:25 PM
@DeadMG You mean std::pair<ReadTexture&, WriteTexture&> where both are references to the same complete object?
 
@CatPlusPlus You need to declare a destructor
@RMartinhoFernandes Yeah
 
For what?
 
I didn't say anything wrong, okay? I'm awesome.
 
because else the impl is an incomplete class and unique_ptr will barf
 
What does make_current() do?
I'm not sure about change_type()..
 
10:26 PM
Er, unique_ptr doesn't require complete type.
 
Getter for the title might be handy.
 
it does for the destructor
 
Why'd you need to get the title?
 
which is implicitly defined for you if you don't define one
in fact, it's explicit in the specification of unique_ptr that it must barf instead of exhibit UB for incomplete types
 
@CatPlusPlus Completeness?
 
10:27 PM
I don't remember ever having problems with no declared destructor and unique_ptr to incomplete type.
 
Aw, no get_position/set_position... ;)
 
You must have the constructor and destructor of both the class and the impl class in the same compilation unit defined explicitly.
 
well, that's curious
GCC seems to be fine with it
 
Boost sometimes overloads the same methodname to define getters and setters. E.g: bool visible() and void visible(bool)
@DeadMG I ran into it lots of times.
 
ah they just went with UB instead
 
10:30 PM
@StackedCrooked change_type is for going from fullscreen to bordered/borderless and vice versa.
 
Needs a better name.
 
maybe it was fixed in a later version of GCC
I know that Visual Studio correctly rejects the code
 
@DeadMG You didn't instantiate the unique_ptr object.
 
oh yeah
kek
 
So no definition is required I'd think.
 
10:31 PM
yes, it is, because the unique_ptr's destructor still calls delete on the T*
 
$ g++-4.7 -std=c++11 -Wall -Wextra -Werror -pedantic-errors test.cpp
test.cpp:12:2: error: extra ';' [-pedantic]
$
@DeadMG Nope.
 
@RMartinhoFernandes In any case
it's not going to magically not be UB to delete an incomplete type just because that deletion is done through unique_ptr
 
But it works!
 
"Google C++ Style Guide". Has anybody got a reference to a description/break down of what is good/bad/ugly about there Guide.
 
10:35 PM
lol
@LokiAstari Google's C++ Style Guide. The good: None. The bad: Lots: The ugly: Absolutely all of it.
 
@DeadMG you haven't seen the GNU style guide.
 
I have the same opinion but would like something to back my opinion up in a discussion.
 
This is really silly. I only learned today that I can specialize a single method (as opposed to a whole class).
 
@StackedCrooked I believe it's a compiler extension. MSVC has the same kind of thing, I think
 
10:37 PM
I think the main problem is people thinking the guide is intended for C++ code everywhere. That guide is for working with the Google codebase, which has lots of legacy code. It's a very specific context.
 
@DeadMG I see.
 
it's certainly not Standard
 
@DeadMG It's the first time I learned something from one of my colleagues. I guess I can now one-up them again by knowing that it isn't standard behavior. Thanks :P
 
You're sure it's not standard? I think so.
 
it certainly wasn't
 
10:38 PM
And GCC in super compliant mode (which is not saying much, I know) agrees.
 
it might be new in C++11
 
$ g++-4.7 -std=c++11 -Wall -Wextra -Werror -pedantic-errors test.cpp
$
 
MSVC always allowed that kind of thing so I never paid too much attention to it
 
8
Q: template class member function only specialization

Tony The LionI am reading the Complete Guide on Templates and it says the following: Where it is talking about class template specialization. However, if you specialize a class template, you must also specialize all member functions. Although it is possible to specialize a single member function,...

Tony asked before!
 
Dammit!
0
Q: Template specialization of a method

StackedCrookedToday a colleague demonstrated this form of specialization to me (compiled with GCC): #include <iostream> #include <sstream> template<typename T> struct Item { Item(const T & value) : value(value) {} std::string toString() const { std::stringstream ss; ...

 
10:45 PM
Close as dupe!
 
Ok :(
 
Well, Tony's question doesn't have any standard references...
 
It does. ..Ah no, it's from Complete Guide on Templates.
Actually I should order that book. Done!
 
Only thing I don't like is that it doesn't have variadic templates and other new stuffs yet :(
 
I should remain silent more often :D
 
10:51 PM
lol
Ooops, wrong keyboard layout.
 
There are also no good books on C++ multithreading. Effective Concurrency still hasn't been released either.
 
    struct ReadWriteTexture {
        const std::shared_ptr<WriteTexture> write;
        const std::shared_ptr<ReadTexture> read;
        operator std::shared_ptr<WriteTexture>() const {
            return write;
        }
        operator std::shared_ptr<ReadTexture>() const {
            return read;
        }
    };
const, I need to add it
 
@RMartinhoFernandes Never heard of it. Is it good?
@RMartinhoFernandes ^-- this
 
@StackedCrooked I have the prerelease version in PDF and while I haven't read much yet, I'd say it looks rather good.
 
10:55 PM
I need to put some clothes on
coding naked is gettin a little cold
 
@StackedCrooked Oh, that will take like forever.
 
@RMartinhoFernandes Interesting. Downloading it.
 
@DeadMG jawdrop
 
@DeadMG If you suddenly wake up from 'the zone' feeling cold and finding yourself in darkness. Then that means that whatever you were doing up until then was damn interesting.
 
well, the heating came off about an hour ago and most of the heat has dissipated
 
11:00 PM
@RMartinhoFernandes Yeah, it deals with all the new stuff.
The chapter on atomic operations should be interesting.
 
You bought it already? Or did you download your personal holiday pictures?
 
Googled for "C++ Concurrency in Action PDF"
It's a draft.
 
Personal holiday pictures it is, then :)
 
@StackedCrooked That's how @Luc refers to torrenting illegal stuff.
0
Q: sizeof class with int , function, virtual function in C++ ?

user1002288This is an online C++ test question, which has been done. #include<iostream> using namespace std; class A { }; class B { int i; }; class C { void foo(); }; class D { virtual void foo(); }; class E { int i ; virtual void foo(); }; class F { int i; void foo(); }; class G { ...

Oh, not this guy again.
 
11:03 PM
87 questions, 0 answers, 45% accept rate ಠ_ಠ
 
@RMartinhoFernandes should I resist the urge to downvote based on recognizing that poster?
 
@daknøk And have a look at the questions.
 
@daknøk most of them are quiz or interview questions he was given
 
@MooingDuck I'm struggling with that same doubt. Rabidly looking for a real reason to justify the downvote :)
 
@daknøk for a while, I went through his history and voted to close most of them as duplicates
 
11:04 PM
@RMartinhoFernandes all in the form of "DO THIS DO THAT OR ELSE……!!!"
 
feel free to just downvote it
I just did
 
@RMartinhoFernandes actually, this question isn't that bad, I'd be hard pressed to find a duplicate I think
 
He never heard of whitespace either.
 
siszeof(A)
 
@DeadMG I noticed.
 
11:06 PM
lol
 
My accept rate is 100% :P noo I accept to much answers! Oh wait…
 
my accept rate is pretty solidly 80% for all time
 
I find that I need two or three more classes in order to use multithreading in C++:
- A "class locker<T>" that bundles a mutex with the type and keeps the mutex locked when providing access to T.
- "worker" class that encapsulates a thread and processes jobs (std::function) from a queue
- maybe "worker_pool" class that accepts jobs and assigns them to the workers.
 
@StackedCrooked If you look in the chat transcript, you can find an implementation of locker<T> that was discussed once.
 
I have a little question regarding RAII. I have a class Repository that represents a directory on disk.
Is it acceptable (good/common practice) to create a lockfile in the constructor and delete it in the destructor, to prevent multiple instances (in the same process and other processes) from opening the same directory?
 
11:10 PM
@RMartinhoFernandes I did it with my ThreadSafe<T> utility. I also did the Worker and WorkerPool classes. I'm just saying I found them necessary to create my Tetris thingy.
 
why would you want to do that at all?
 
@StackedCrooked Wait, I now see that you were involved in that discussion. Nevermind.
 
usually, a named mutex is used, or a locked file in the temporaries directory
 
@daknøk Or inherit the lockfile privately.
 
@DeadMG I don't want multiple instances to change the same files at the same time, since that can lead to corruption of the repository.
 
11:12 PM
why not just lock each file per access, and hell, per access type?
there's no need to lock the whole directory
I know that Windows and probably POSIX too allow you to lock a file for reading or writing when you open it
 
Some files contain references to other files within the same directory, e.g. the info file contains the date of the latest revision. This must be kept in sync.
 
// You mean something like this?
struct LockFile {
    LockFile(const std::string & filename) : filename(filename) {
        ::PlatformLockFile(filename.c_str());
    }
    ~LockFile() {
        ::PlatformUnlockFile(filename.c_str());
    }
    std::string filename;
};
 
ah
so we're not really talking about a normal directory then at all
 
@DeadMG it's a special directory, similar to what git and subversion use (.git and .svn).
@StackedCrooked I'm currently using something like this:
 
but yes, you can use a named object like a named mutex or file, to prevent such things
 
11:16 PM
class Repo {
public:
    Repo(const std::string& dir_path) : dir_path_(dir_path) {
        // some code first to throw if lock file already exists
        // else…
        create_lockfile_in_dir(dir_path);
    }
    ~Repo() { delete_lockfile_in_dir(dir_path_); }
private:
    std::string dir_path_;
};
 
forgot non-copyable
 
Ouh, I did.
 
@DeadMG thanks for noticing!
 
yeah, um, I didn't forget really, it's just, the imaginary API doesn't mind if I unlock twice.
 
Rule of Three
 
11:17 PM
Rule of noncopyable unless not.
 
Ha, found my range-based for loop abuse for scoped locking: ideone.com/HK4Kw
 
We need a wiki page for ideone pastes
 
@Pubby I keep them properly tagged in my account.
But some old ones are from before I set up an account.
    for(auto& x : box.open()) {
        x.do_racy_stuff();
        x.do_more_racy_stuff();
        x.do_really_raunchy_stuff();
    }
Love it!
 
@RMartinhoFernandes Yep, nice.
Actually I didn't notice it holds multiple objects.
 
It doesn't.
 
11:20 PM
@DeadMG so I need to do Repo(const Repo&) = delete; and Repo& operator=(const Repo&) = delete;, right?
 
Does no-rtti make the binary more "obfuscated"?
 
@StackedCrooked It's only one. The for loop is a hack.
 
Oh, no it doesn't.
That's quite clever indeed.
 
@Pubby implementation-defined. :trollface:
 
I'm just wondering if rtti makes C++ easier to decompile
 
11:22 PM
for (auto & x : box.open()) Is lifetime ok here? You can't bind a temporary to a non-const ref and extend it's lifetime.
 
@Pubby wait, I'm trying something…
 
@StackedCrooked You can bind to a non-const ref if you have a non-const ref: T& operator*().
The "temporary" is the iterator, which lasts for the entire loop.
 
I see that now.
It's goes deeper than I thought.
I had a macro based solution inspired on BOOST_FOREACH. However, it's not nearly as nice as this.
The raunchiness is wearing me down though.
 
@Pubby ignore my last message.
 
11:28 PM
@Pubby Not really, no.
 
@Pubby someone still has to come up with a class-dump for C++. :P
But it's virtually impossible, especially with all the optimizations that C++ compilers can perform.
 
You mean, something like this telerik.com/products/decompiler.aspx?
Also, damn you RedGate, Reflector was awesome.
 
@RMartinhoFernandes We need a place where we can post cool C++ techniques and tricks. There are probably many cool ideas out there.
I was very impressed with boost bind when I first learned about it. And that was just C++03. I expect to be blown away by the C++11 generation of libraries.
 
@StackedCrooked Like a wiki of sorts.
I wonder where we can find one of these.
 
11:35 PM
Yeah, or perhaps something like an SO faq (e.g. What is the copy-and-swap idiom? ).
 
hmmm
do I really need a separate depth buffer per render target?
wait, yes, I do
 
@CatPlusPlus Disguising TVTropes links like that shows a profound lack of character!
 
Just invent a name for your technique and make a FAQ post: "What is <my_technique>?" :D
 
@StackedCrooked Erm, that sounds like abuse.
 
11:37 PM
It's only abuse if your technique sucks.
 
What about… a subreddit?
 
That's an option.
1 message moved to bin
 
D:
 
@Hoxieboy :D
 
What happened?
 
11:38 PM
It
 
Es.
 
We have a wiki, we don't need subreddits.
I can even make a forum on the wiki.
 
@Cat make a nice page like you did for the project things. You're the one that knows the magicks.
 
BECAUSE WIKI IS AWESOME.
 
@RMartinhoFernandes what about me D:
 
11:39 PM
What about you? What are you talking about?
 
Nah jk cat is wizard
 
Ooookay.
> Well I know that, but I want my C++ programs to run all on Operating systems like C++ can. – user1078510 19 mins ago
Someone looking for a tool to pack all DLLs his program uses into "a single EXE".
 
I don't think there's a need for strict form here.
 
The layout is a little messed up in the Wiki.
 
What do you mean?
 
11:44 PM
Oh god no, interview spam guy is back!
 
Yeah, we noticed.
 
The tabs. As if anyone f•cking cares.
 
Indeed.
 
Well, your windows are too narrow.
 
oh man
TVTropes linked me to Cracked
 
11:45 PM
Lol.
Victory.
 
user406009
@CatPlusPlus What size windows do you expect us to have?
 
user406009
Maximized on my screen is same problem.
 
@CatPlusPlus it's fullscreen, I can't make it wider very easy
 
Maximized across my two screens fixes it.
 
I don't know, larger than 640x480?
 
11:46 PM
@CatPlusPlus my browser is currently 1280 wide, still overlaps
 
Jan 27 at 2:52, by R. Martinho Fernandes
Why would TVTropes link to Cracked? That's gotta be against Human Rights.
 
I have to make my window less than 660px wide for it to overlap.
 
My windows is 1280px wide and it overlaps.
 
@CatPlusPlus what browser? I got chrome
 
Well, dunno, report the bug to Wikidot, it's their layout.
 
11:48 PM
My default font is Droid Sans, size 16.
Gosh, that sounds big.
 
user406009
1280 here as well.
 
@MooingDuck Chrome.
 
lol failure on my screen:
 
@daknøk Should layouted using something like a FormLayout in SWT. (Align child componenets relative to each other.) (At least that's how I'd do it in a desktop app. Don't have experience with layouting stuff on the web.)
 
@CatPlusPlus interesting
 
11:49 PM
@StackedCrooked FormLayout? SWT?
 
Maybe you've got some cache weirdness.
 
@RMartinhoFernandes Oh, right.
 
Actually, the tabs overlap on my computer in chrome, firefox, IE, and safari
 
Layouting stuff on the web is primarily guessing and praying it will work.
 
@CatPlusPlus maybe they should test it once, with a browser
 
11:50 PM
@CatPlusPlus are python projects allowed on the wiki as well? just wondering :)
 
@CatPlusPlus Or the other way around.
 
@Hoxieboy sure. Just not Java
 
@CatPlusPlus Not with the new magic CSS "computed style".
 
rofl
 
@Hoxieboy @CatPlusPlus I would suggest to hide or remove all non-relevant links for normal users. The first time I visited the page I was looking for content in the box on the left.
 
11:50 PM
@MooingDuck Clearly once isn't enough: it works for the Cat.
 
@RMartinhoFernandes I think he's lying, since he lacks confirmation (third party verification)
 
user406009
Why are you guys so biased against Java?
 
@CatPlusPlus That has been my experience as well. But I thought that was because of lack of experience.
 
@EthanSteinberg BECAUSE JAVA IS TERRIBLE IN EVERY CONCEIVABLE WAY!
9
 
user406009
It is not that bad of a language(compared to PHP/javascript)
 
11:51 PM
@MooingDuck except interwebs :P
 
@EthanSteinberg You. Out of my chatroom.
 
@EthanSteinberg Yeah, but it's a meme.
 
I also think we need more colors.
 
@daknøk or not
 
11:52 PM
@daknøk and a nyan cat?
 
Can't see! I'm blind! Help!
 
:s
 
1 message moved to bin
 
@RMartinhoFernandes Use a screen reader that tells colors.
 
Oooh!
 
11:53 PM
shakes fist
 
@CatPlusPlus lol wth?
 
The cat was not amused.
 
He broke the robot!
 
oh noes
 
@CatPlusPlus that sounds wrong, just wrong.
 
11:54 PM
@StackedCrooked Well, I'm not sure where to put it otherwise.
 
It was a color coded virus!
 
Okay, let's try something.
 
@CatPlusPlus Maybe an "admin" tab.
 
@CatPlusPlus How about a python tab eh >.>?
 
user406009
If we add an "admin" tab we should add a "meta" tab. Then meta will take over the wiki. Then we will be back where we started.
 
11:56 PM
Ok, I rebooted the EM analyser and I can see again.
 
@RMartinhoFernandes flashes with blinding blue laser light
 

« first day (496 days earlier)      last day (4451 days later) »