ChessPlusPlus Questions

Pages: 12
closed account (N36fSL3A)
Is this open-source? I'd love to see some networking code.
Is what open source? The answer is yes, because all of the things mentioned that you could possibly be referring to are open source (ChessPlusPlus, SFML, Boost, Lacewing).
closed account (N36fSL3A)
I was referring to ChessPlusPlus. Where can I see the source?
Hehe, GitHub needs to learn to combine common stream activities into more concise messages:
http://i.imgur.com/UKKihuY.png

It doesn't bother me, I just find it funny :)
ResidentBiscuit wrote:
There is a library called SFGUI that claims it is for SFML applications.
That might be worth trying out.[/quote]I could never get SFGUI to compile. I was planning on writing a quick and dirty GUI module that works well enough for our purposes (a menu, a quit button, pause screen, etc). That said, I haven't gotten around to it just yet, so if that's something you can/want to do, go at it.

L B wrote:
if each state class had a static function changeTo that too the application, and it would call changeState for you.
Yeah I would do that in the actual implementation. I threw this together for RB without thinking too much about it -- it was meant to be almost purely conceptual.
Last edited on
I'll mess around with SFGUI, see if I can get it working.

Anyways, going through the code getting an understanding, not understanding what this snippet does. It's from Application.hpp
https://github.com/ResidentBiscuit/ChessPlusPlus/blob/lb-refactor/src/Application.hpp

1
2
3
4
5
6
7
8
9
template<class NewState, typename... Args>
        void changeState(Args... args)
        {
            //make sure we can create the new state first
            std::unique_ptr<AppState> temp {new NewState(std::forward<Args>(args)...)};
            //then swap ownership
            state.swap(temp);
            //temp properly deletes the old state at the end of its scope
        }


For some reason, this block of code has me lost.
I'm not too familiar with variadic templates or std::forward but it looks like it's creating a unique_ptr from a state passed as template arg and swapping it with the classes unique_ptr.

http://www.cplusplus.com/reference/utility/forward/
http://www.cplusplus.com/articles/EhvU7k9E/
http://www.cplusplus.com/reference/memory/unique_ptr/
@ResidentBiscuit: it's a use-case for perfect forwarding. It's a lot like .emplace(...) in most C++ containers, except in this case we're creating a new state from the passed arguments, swapping it with the current state, and letting the old state go out of scope and get destroyed.

EDIT: The only issue is, I forgot the && between "Args" and "..." in the parameter list, so it isn't actually perfect forwarding until I fix it :)

EDIT: https://github.com/LB--/ChessPlusPlus/commit/15705a2081af70c649a5cd059eb215660dfdaae8
Can't test it, but I am 50% sure it should still work.
Last edited on
In case anyone is interested, the project can be built with VS2013 by removing all the noexcept's, defaulted move ctors and defaulted assignment operators plus a few other minor changes.

The project compiles but only runs for me in release, but debug gives "map/set iterators incompatible" exception.
Last edited on
@LB, Hmm thanks. I'll look into this, I'm not very familiar with much C++11 yet :(
@ResidentBiscuit: then you'll love what I am currently obsessing myself with:
https://github.com/LB--/hSDK/blob/Fusion-2.x/include/hSDK/Extension.hpp
(As of this post it's still a WIP and probably has some compile errors) EDIT: Now mostly complete
Last edited on
Topic archived. No new replies allowed.
Pages: 12