ivl 679
ivl/details/core/types/extraction.hpp
00001 /* This file is part of the ivl C++ library <http://image.ntua.gr/ivl>.
00002    A C++ template library extending syntax towards mathematical notation.
00003 
00004    Copyright (C) 2012 Yannis Avrithis <iavr@image.ntua.gr>
00005    Copyright (C) 2012 Kimon Kontosis <kimonas@image.ntua.gr>
00006 
00007    ivl is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU Lesser General Public License 
00009    version 3 as published by the Free Software Foundation.
00010 
00011    Alternatively, you can redistribute it and/or modify it under the terms 
00012    of the GNU General Public License version 2 as published by the Free 
00013    Software Foundation.
00014 
00015    ivl is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00018    See the GNU General Public License for more details.
00019 
00020    You should have received a copy of the GNU General Public License 
00021    and a copy of the GNU Lesser General Public License along 
00022    with ivl. If not, see <http://www.gnu.org/licenses/>. */
00023 
00024 #ifndef IVL_CORE_DETAILS_TYPES_EXTRACTION
00025 #define IVL_CORE_DETAILS_TYPES_EXTRACTION
00026 
00027 namespace ivl {
00028 namespace types {
00029 
00030 /*
00031 Template types extraction.
00032 Helps us extract a desired parameter
00033 from a template class.
00034 */
00035 
00036 
00037 
00038 template<int I, class F>
00039 struct get_templ_arg { };
00040 
00041 // get the type T itself for a non-template class.
00042 template<class T>
00043 struct get_templ_arg<1, T> { typedef T type; }
00044 
00045 // classes of 2 class arguments
00046 template<template<typename, typename> class F,
00047 class T1, class T2>
00048 struct get_templ_arg<1, F<T1, T2> > { typedef T1 type; };
00049 
00050 template<template<typename, typename> class F,
00051 class T1, class T2>
00052 struct get_templ_arg<2, F<T1, T2> > { typedef T2 type; };
00053 
00054 // classes of 3 class arguments
00055 template<template<typename, typename, typename> class F,
00056 class T1, class T2, class T3>
00057 struct get_templ_arg<1, F<T1, T2, T3> > { typedef T1 type; };
00058 
00059 template<template<typename, typename, typename> class F,
00060 class T1, class T2, class T3>
00061 struct get_templ_arg<2, F<T1, T2, T3> > { typedef T2 type; };
00062 
00063 template<template<typename, typename, typename> class F,
00064 class T1, class T2, class T3>
00065 struct get_templ_arg<3, F<T1, T2, T3> > { typedef T3 type; };
00066 
00067 // classes of 4 class arguments
00068 template<template<typename, typename, typename, typename> class F,
00069 class T1, class T2, class T3, class T4>
00070 struct get_templ_arg<1, F<T1, T2, T3, T4> > { typedef T1 type; };
00071 
00072 template<template<typename, typename, typename, typename> class F,
00073 class T1, class T2, class T3, class T4>
00074 struct get_templ_arg<2, F<T1, T2, T3, T4> > { typedef T2 type; };
00075 
00076 template<template<typename, typename, typename, typename> class F,
00077 class T1, class T2, class T3, class T4>
00078 struct get_templ_arg<3, F<T1, T2, T3, T4> > { typedef T3 type; };
00079 
00080 template<template<typename, typename, typename, typename> class F,
00081 class T1, class T2, class T3, class T4>
00082 struct get_templ_arg<4, F<T1, T2, T3, T4> > { typedef T4 type; };
00083 
00084 
00085 
00086 
00087 
00088 } /* namespace types */
00089 } /* namespace ivl */
00090 
00091 #endif // IVL_CORE_DETAILS_TYPES_EXTRACTION
 All Classes Namespaces Files Functions Variables Typedefs Enumerations