Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 8, 2015, 10:40:44 AM (9 years ago)
Author:
landauf
Message:

using std::bind and std::function instead of boost::bind and boost::function respectively. use arg:: namespace for placeholders to avoid ambiguity with boost-placeholders

Location:
code/branches/cpp11_v2/src/libraries
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/libraries/core/GUIManager.cc

    r10773 r10775  
    3232#include <fstream>
    3333#include <memory>
    34 #include <boost/bind.hpp>
     34#include <functional>
    3535#include <OgreRenderQueue.h>
    3636#include <OgreRenderWindow.h>
     
    115115namespace orxonox
    116116{
     117    namespace arg = std::placeholders;
     118
    117119    static void key_esc()
    118120        { GUIManager::getInstance().keyESC(); }
     
    451453    {
    452454        assert(guiSystem_);
    453         this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectTimePulse, _1, time.getDeltaTime()));
     455        this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectTimePulse, arg::_1, time.getDeltaTime()));
    454456    }
    455457
     
    627629    {
    628630#if CEGUI_VERSION >= 0x000800
    629         this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectKeyDown, _1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work?
    630         this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectChar, _1, evt.getText()));
    631 #else
    632         this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectKeyDown, _1, evt.getKeyCode()));
    633         this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectChar, _1, evt.getText()));
     631        this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectKeyDown, arg::_1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work?
     632        this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectChar, arg::_1, evt.getText()));
     633#else
     634        this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectKeyDown, arg::_1, evt.getKeyCode()));
     635        this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectChar, arg::_1, evt.getText()));
    634636#endif
    635637    }
     
    638640    {
    639641#if CEGUI_VERSION >= 0x000800
    640         this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectKeyUp, _1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work?
    641 #else
    642         this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectKeyUp, _1, evt.getKeyCode()));
     642        this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectKeyUp, arg::_1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work?
     643#else
     644        this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectKeyUp, arg::_1, evt.getKeyCode()));
    643645#endif
    644646    }
     
    656658    {
    657659#if CEGUI_VERSION >= 0x000800
    658         this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseButtonDown, _1, convertButton(id)));
    659 #else
    660         this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseButtonDown, _1, convertButton(id)));
     660        this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectMouseButtonDown, arg::_1, convertButton(id)));
     661#else
     662        this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectMouseButtonDown, arg::_1, convertButton(id)));
    661663#endif
    662664    }
     
    674676    {
    675677#if CEGUI_VERSION >= 0x000800
    676         this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseButtonUp, _1, convertButton(id)));
    677 #else
    678         this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseButtonUp, _1, convertButton(id)));
     678        this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectMouseButtonUp, arg::_1, convertButton(id)));
     679#else
     680        this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectMouseButtonUp, arg::_1, convertButton(id)));
    679681#endif
    680682    }
     
    683685    {
    684686#if CEGUI_VERSION >= 0x000800
    685         this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMousePosition, _1, (float)abs.x, (float)abs.y));
    686 #else
    687         this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMousePosition, _1, (float)abs.x, (float)abs.y));
     687        this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectMousePosition, arg::_1, (float)abs.x, (float)abs.y));
     688#else
     689        this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectMousePosition, arg::_1, (float)abs.x, (float)abs.y));
    688690#endif
    689691    }
     
    692694    {
    693695#if CEGUI_VERSION >= 0x000800
    694         this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseWheelChange, _1, (float)sgn(rel) * this->numScrollLines_));
    695 #else
    696         this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseWheelChange, _1, (float)sgn(rel) * this->numScrollLines_));
     696        this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectMouseWheelChange, arg::_1, (float)sgn(rel) * this->numScrollLines_));
     697#else
     698        this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectMouseWheelChange, arg::_1, (float)sgn(rel) * this->numScrollLines_));
    697699#endif
    698700    }
     
    704706    {
    705707#if CEGUI_VERSION >= 0x000800
    706         this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseLeaves, _1));
    707 #else
    708         this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseLeaves, _1));
     708        this->protectedCeguiContextCall(std::bind(&CEGUI::GUIContext::injectMouseLeaves, arg::_1));
     709#else
     710        this->protectedCeguiSystemCall(std::bind(&CEGUI::System::injectMouseLeaves, arg::_1));
    709711#endif
    710712    }
     
    753755        terminate the whole program...
    754756    @note
    755         Your life gets easier if you use boost::bind to create the object/function.
     757        Your life gets easier if you use std::bind to create the object/function.
    756758    @param function
    757759        Any callable object/function that takes this->guiSystem_ as its only parameter.
  • code/branches/cpp11_v2/src/libraries/core/Thread.cc

    r10768 r10775  
    3434
    3535#include <cassert>
     36#include <functional>
    3637#include <boost/thread/thread.hpp>
    37 #include <boost/bind.hpp>
    3838#include <boost/thread/mutex.hpp>
    3939#include <boost/thread/thread_time.hpp>
     
    5555        this->isWorkingMutex_ = new boost::mutex;
    5656        this->stopThreadMutex_ = new boost::mutex;
    57         this->workerThread_ = new boost::thread( boost::bind(&Thread::threadLoop, this) );
     57        this->workerThread_ = new boost::thread( std::bind(&Thread::threadLoop, this) );
    5858    }
    5959
  • code/branches/cpp11_v2/src/libraries/core/ThreadWin.cc

    r10768 r10775  
    3131
    3232#include <cassert>
     33// #include <functional>
    3334// #include <boost/thread/thread.hpp>
    34 // #include <boost/bind.hpp>
    3535// #include <boost/thread/mutex.hpp>
    3636// #include <boost/thread/thread_time.hpp>
     
    5252//         this->isWorkingMutex_ = new boost::mutex;
    5353//         this->stopThreadMutex_ = new boost::mutex;
    54 //         this->workerThread_ = new boost::thread( boost::bind(&Thread::threadLoop, this) );
     54//         this->workerThread_ = new boost::thread( std::bind(&Thread::threadLoop, this) );
    5555    }
    5656
  • code/branches/cpp11_v2/src/libraries/core/command/TclThreadManager.cc

    r10768 r10775  
    3434#include "TclThreadManager.h"
    3535
    36 #include <boost/bind.hpp>
     36#include <functional>
    3737#include <boost/thread/thread.hpp>
    3838#include <boost/thread/locks.hpp>
     
    163163                                {
    164164                                    // Start a thread to execute the command
    165                                     boost::thread(boost::bind(&tclThread, bundle, command));
     165                                    boost::thread(std::bind(&tclThread, bundle, command));
    166166                                }
    167167                                else
     
    488488    void TclThreadManager::source(const std::string& file)
    489489    {
    490         boost::thread(boost::bind(&sourceThread, file));
     490        boost::thread(std::bind(&sourceThread, file));
    491491    }
    492492
  • code/branches/cpp11_v2/src/libraries/core/input/InputManager.h

    r10769 r10775  
    3535#include <string>
    3636#include <vector>
    37 #include <boost/function.hpp>
     37#include <functional>
    3838
    3939#include "util/Singleton.h"
     
    186186        // Function call caching
    187187        //-------------------------------
    188         void pushCall(const boost::function<void ()>& function)
     188        void pushCall(const std::function<void ()>& function)
    189189            { this->callBuffer_.push_back(function); }
    190190
     
    225225        std::vector<InputState*>            activeStatesTicked_;   //!< Like activeStates_, but only contains the ones that currently receive events
    226226
    227         std::vector<boost::function<void ()>> callBuffer_;        //!< Caches all calls from InputStates to be executed afterwards (see preUpdate)
     227        std::vector<std::function<void ()>> callBuffer_;        //!< Caches all calls from InputStates to be executed afterwards (see preUpdate)
    228228
    229229        static InputManager*                singletonPtr_s;        //!< Pointer reference to the singleton
  • code/branches/cpp11_v2/src/libraries/core/input/InputState.h

    r10765 r10775  
    3535#include <string>
    3636#include <vector>
    37 #include <boost/function.hpp>
    38 #include <boost/bind.hpp>
     37#include <functional>
    3938
    4039#include "util/tribool.h"
     
    4443
    4544#define INPUT_STATE_PUSH_CALL(deviceIndex, functionName, ...) \
    46     InputManager::getInstance().pushCall(boost::function<void ()>(boost::bind(&InputHandler::functionName, handlers_[deviceIndex], __VA_ARGS__)))
     45    InputManager::getInstance().pushCall(std::function<void ()>(std::bind(&InputHandler::functionName, handlers_[deviceIndex], __VA_ARGS__)))
    4746
    4847namespace orxonox
     
    212211            // We have to store the function pointer to tell the compiler about its actual type because of overloading
    213212            void (InputHandler::*function)(unsigned int, ButtonTypeParam, EventType) = &InputHandler::buttonEvent<ButtonTypeParam>;
    214             InputManager::getInstance().pushCall(boost::function<void ()>(boost::bind(function, handlers_[device], device, button, EventType())));
     213            InputManager::getInstance().pushCall(std::function<void ()>(std::bind(function, handlers_[device], device, button, EventType())));
    215214        }
    216215    }
  • code/branches/cpp11_v2/src/libraries/network/TrafficControl.cc

    r10769 r10775  
    3030
    3131#include <cassert>
    32 #include <boost/bind.hpp>
     32#include <functional>
    3333
    3434#include "core/CoreIncludes.h"
     
    3939
    4040  static const unsigned int SCHED_PRIORITY_OFFSET = static_cast<unsigned int>(-1);
     41  namespace arg = std::placeholders;
    4142
    4243  objInfo::objInfo(uint32_t ID, uint32_t creatorID, int32_t curGsID, int32_t diffGsID, uint32_t size, unsigned int prioperm, unsigned int priosched)
     
    258259
    259260      //sort copied list according to priorities
    260       // use boost bind here because we need to pass a memberfunction to stl sort
    261 //       sort( list.begin(), list.end(), boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
    262       list.sort( boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
    263 
    264 //       list.sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) );
     261      // use std::bind here because we need to pass a memberfunction to stl sort
     262//       sort( list.begin(), list.end(), std::bind(&TrafficControl::prioritySort, this, clientID, arg::_1, arg::_2) );
     263      list.sort( std::bind(&TrafficControl::prioritySort, this, clientID, arg::_1, arg::_2) );
     264
     265//       list.sort(std::bind(&TrafficControl::prioritySort, this, clientID, arg::_1, arg::_2) );
    265266
    266267      //now we check, that the creator of an object always exists on a client
     
    275276      cut(list, targetSize);
    276277      //now sort again after objDataOffset
    277 //       sort(list.begin(), list.end(), boost::bind(&TrafficControl::dataSort, this, _1, _2) );
    278       list.sort( boost::bind(&TrafficControl::dataSort, this, _1, _2) );
     278//       sort(list.begin(), list.end(), std::bind(&TrafficControl::dataSort, this, arg::_1, arg::_2) );
     279      list.sort( std::bind(&TrafficControl::dataSort, this, arg::_1, arg::_2) );
    279280
    280281      //diese Funktion updateClientList muss noch gemacht werden
Note: See TracChangeset for help on using the changeset viewer.