ivl 679
|
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_DATA_MEMBER_CONTROL_HPP 00025 #define IVL_CORE_DETAILS_DATA_MEMBER_CONTROL_HPP 00026 00027 /* This file provides some helper structs that call member functions 00028 for array classes with certain conditions, for example some members 00029 are only defined in arrays with has_random_access = to types::t_true. 00030 The helper functions allow us to call a member only if it exists, 00031 or to do something else in other cases, depending on a certain type. */ 00032 00033 namespace ivl { 00034 namespace data { 00035 00036 template<class T> 00037 struct call_if : public call_if<typename T::type> { }; 00038 00039 template<> 00040 struct call_if<types::t_true> 00041 { 00042 template<class C, class A> static inline 00043 void resize(C c, A a) { c.resize(a); } 00044 }; 00045 00046 template<> 00047 struct call_if<types::t_false> 00048 { 00049 template<class C, class A> static inline 00050 void resize(C c, A a) { } 00051 }; 00052 00053 00054 00055 } /* namespace data */ 00056 } /* namespace ivl */ 00057 00058 #endif // IVL_CORE_DETAILS_DATA_MEMBER_CONTROL_HPP