Results 1 to 4 of 4

Thread: [ClanLib 3] Variadic template replacement

  1. #1

    Default [ClanLib 3] Variadic template replacement

    I converted the callbacks, signals and the NetGameDispatcher to use variadic templates introduced in C++11. Visual C++ 2012 should support this to some extent via faux variadic templates.

    Callbacks do not work with GCC 4.8.1 (but they work on clang). This also affects NetGameDispatcher since it uses Callbacks. GCC will throw an error whenever you call Callback::set().
    Update: Adding spaces in between seems to fix the error.

    Files affected:
    API/Core/Signals/signal.h (replace signal_v#.h)
    API/Core/Signals/slot_container.h
    API/Core/Signals/callback.h (replace callback_[v]#.h)
    API/Network/NetGame/event_dispatcher.h
    variadic_test.cpp (does not test event_dispatcher)
    Attached Files Attached Files
    Last edited by moogtrain; 07-21-2013 at 10:46 AM. Reason: callback.h replaces callback_# and callback_v# files

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    http://msdn.microsoft.com/en-us/libr.../hh567368.aspx "C++11 Features (Modern C++)"

    Variadic templates v0.9, v1.0

    Visual Studio 2010 = No
    Visual Studio 2012 = No

    Haven't tested it though

  3. #3

    Default

    C++11 provide std::functions (and std::bind) that can store lambda, functors, methods, and callbacks. The implementation of std::function rely on variadic templates. If C++11 was supported by VC++, I think it may be really cool to use std::functions. But it seams VC++ compiler won't support variadic templates until a long time (the team developing VC's stl implementation seams to be complaining about the absence of variadic templates and the need to emulate them, where they can, throught macros). So your patch won't probably compile with VC's compiler.

  4. #4

    Default

    I made a mistake. VS2012 does not support variadic templates, but VS2012 November CTP does support it via library emulation. VS2013 Preview was released with actual support with variadic templates. I have just tested the code and it compiles fine there.

    The only problem with this patch is that we would have to drop support for VS08, 10 and 12.

Similar Threads

  1. A New Replacement for A Horsie Or Air Robinson
    By awesome2505 in forum Suggestion Box
    Replies: 10
    Last Post: 05-19-2013, 12:29 AM
  2. Replies: 0
    Last Post: 05-18-2013, 05:42 AM
  3. Replies: 7
    Last Post: 08-26-2008, 09:57 PM
  4. problems with clanlib template from kdevelop
    By harry666t in forum Official ClanLib SDK Forums
    Replies: 5
    Last Post: 02-19-2008, 11:31 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •