MACE  1.0.0
 All Classes Namespaces Files Functions Variables Enumerations Defines
libs/stub/include/mace/stub/void.hpp
00001 #ifndef __MACE_STUB_VOID_HPP__
00002 #define __MACE_STUB_VOID_HPP__
00003 #include <iostream>
00004 
00005 namespace mace { namespace stub {
00014     struct void_t{
00015         friend std::ostream& operator<<(std::ostream& os,const void_t&) {return os;}
00016         friend std::istream& operator>>(std::istream& is,void_t&)       {return is;}
00017     };
00018 
00027     template<typename R, typename Functor=int>
00028     struct adapt_void {
00029         typedef R result_type;
00030 
00031         adapt_void( const Functor _f):f(_f){}
00032 
00033         template<typename Seq>
00034         result_type operator()( const Seq& seq )const {
00035             return f(seq);
00036         }
00037         template<typename Seq>
00038         result_type operator()( Seq& seq )const {
00039             return f(seq);
00040         }
00041         Functor f;
00042     };
00043     #ifndef DOXYGEN
00044     template<typename Functor>
00045     struct adapt_void<void,Functor> {
00046         typedef void_t result_type;
00047         adapt_void( const Functor _f):f(_f){}
00048 
00049         template<typename Seq>
00050         result_type operator()( const Seq& seq )const {
00051             f(seq); return result_type();
00052         }
00053         template<typename Seq>
00054         result_type operator()( Seq& seq )const {
00055             f(seq); return result_type();
00056         }
00057         Functor f;
00058     };
00059     #endif
00060 } }
00061 
00062 #endif