Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE) 00002 // 00003 // This file is part of Olena. 00004 // 00005 // Olena is free software: you can redistribute it and/or modify it under 00006 // the terms of the GNU General Public License as published by the Free 00007 // Software Foundation, version 2 of the License. 00008 // 00009 // Olena is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 // As a special exception, you may use this file as part of a free 00018 // software project without restriction. Specifically, if other files 00019 // instantiate templates or use macros or inline functions from this 00020 // file, or you compile this file and link it with other files to produce 00021 // an executable, this file does not by itself cause the resulting 00022 // executable to be covered by the GNU General Public License. This 00023 // exception does not however invalidate any other reasons why the 00024 // executable file might be covered by the GNU General Public License. 00025 00026 #include <mln/trait/op/uminus.hh> 00027 #include <mln/core/concept/object.hh> 00028 #include <mln/value/int_u8.hh> 00029 00030 00031 namespace my 00032 { 00033 00034 00035 // Value. 00036 00037 template <typename E> struct Value; 00038 00039 template <> struct Value<void> { typedef mln::Object<void> super; }; 00040 00041 template <typename E> 00042 struct Value 00043 { 00044 typedef Value<void> category; 00045 protected: 00046 Value() {} 00047 }; 00048 00049 00050 // Integer. 00051 00052 template <typename E> struct Integer; 00053 00054 template <> struct Integer<void> { typedef Value<void> super; }; 00055 00056 template <typename E> 00057 struct Integer 00058 { 00059 typedef Integer<void> category; 00060 }; 00061 00062 template <> 00063 struct Integer<int> 00064 { 00065 typedef Integer<void> category; 00066 int i; 00067 Integer(int i) : i(i) {} 00068 }; 00069 00070 00071 // Built_In. 00072 00073 template <typename E> struct Built_In; 00074 00075 template <> struct Built_In<void> { typedef void* super; }; // cause several posible 00076 00077 00078 // test. 00079 00080 struct test // like a built-in: no inheritance! 00081 { 00082 void is_test() {} 00083 }; 00084 00085 // FIXME: Dead code? 00086 // template <typename I> 00087 // void foo(const Integer<I>&) 00088 // { 00089 // std::cout << "Int" << std::endl; 00090 // } 00091 00092 // template <typename I> 00093 // void foo(const Value<I>&) 00094 // { 00095 // std::cout << "Value" << std::endl; 00096 // } 00097 00098 } // my 00099 00100 00101 00102 namespace mln 00103 { 00104 00105 template <> 00106 struct category< my::test > 00107 { 00108 typedef my::Built_In< my::Integer<void> > ret; 00109 }; 00110 00111 // template <> 00112 // struct category< int > 00113 // { 00114 // typedef my::Built_In< my::Integer<void> > ret; 00115 // }; 00116 00117 namespace trait 00118 { 00119 00120 template <typename T> 00121 struct set_unary_< op::uminus, my::Integer, T > 00122 { 00123 typedef bool ret; 00124 }; 00125 00126 } // mln::trait 00127 00128 } // mln 00129 00130 00131 int main() 00132 { 00133 using namespace mln; 00134 00135 mln_trait_op_uminus_(my::test) tmp; 00136 tmp = true; 00137 00138 // int i; 00139 // my::foo<int>(i); 00140 00141 // mln_trait_op_plus_(value::int_u8, int) t; 00142 // void* v = t; 00143 }