src/Lib/shttl/integer.h

説明を見る。
00001 // 
00002 // Copyright (c) 2005-2008 Kenichi Watanabe.
00003 // Copyright (c) 2005-2008 Yasuhiro Watari.
00004 // Copyright (c) 2005-2008 Hironori Ichibayashi.
00005 // Copyright (c) 2008-2009 Kazuo Horio.
00006 // Copyright (c) 2009-2013 Naruki Kurata.
00007 // Copyright (c) 2005-2013 Ryota Shioya.
00008 // Copyright (c) 2005-2013 Masahiro Goshima.
00009 // 
00010 // This software is provided 'as-is', without any express or implied
00011 // warranty. In no event will the authors be held liable for any damages
00012 // arising from the use of this software.
00013 // 
00014 // Permission is granted to anyone to use this software for any purpose,
00015 // including commercial applications, and to alter it and redistribute it
00016 // freely, subject to the following restrictions:
00017 // 
00018 // 1. The origin of this software must not be misrepresented; you must not
00019 // claim that you wrote the original software. If you use this software
00020 // in a product, an acknowledgment in the product documentation would be
00021 // appreciated but is not required.
00022 // 
00023 // 2. Altered source versions must be plainly marked as such, and must not be
00024 // misrepresented as being the original software.
00025 // 
00026 // 3. This notice may not be removed or altered from any source
00027 // distribution.
00028 // 
00029 // 
00030 
00031 
00032 #ifndef SHTTL_INTEGER_H
00033 #define SHTTL_INTEGER_H
00034 
00035 #include "shttl_types.h"
00036 
00037 namespace shttl 
00038 {
00039 
00040     //
00041     //  integer_base<T> 
00042     //
00043 
00044     template<class T>
00045     class integer_base {
00046     private:
00047         T _t;
00048 
00049     public:
00050         integer_base(T t = T()) : _t(t) {}
00051         operator T() const { return _t; }
00052 
00053     }; 
00054 
00055 
00056     //
00057     //  General Version
00058     //
00059 
00060     template<size_t N>
00061     struct integer : public integer_base<u64> {
00062         integer(u64 t = 0) : integer_base<u64>(t) {}
00063     };
00064 
00065 
00066     //
00067     //  Special Versions for 1 .. 8
00068     //
00069 
00070     template<>
00071     struct integer<1> : public integer_base<u8> {
00072         integer(u8 t = 0) : integer_base<u8>(t) {}
00073     };
00074 
00075     template<>
00076     struct integer<2> : public integer_base<u8> {
00077         integer(u8 t = 0) : integer_base<u8>(t) {}
00078     };
00079 
00080     template<>
00081     struct integer<3> : public integer_base<u8> {
00082         integer(u8 t = 0) : integer_base<u8>(t) {}
00083     };
00084 
00085     template<>
00086     struct integer<4> : public integer_base<u8> {
00087         integer(u8 t = 0) : integer_base<u8>(t) {}
00088     };
00089 
00090     template<>
00091     struct integer<5> : public integer_base<u8> {
00092         integer(u8 t = 0) : integer_base<u8>(t) {}
00093     };
00094 
00095     template<>
00096     struct integer<6> : public integer_base<u8> {
00097         integer(u8 t = 0) : integer_base<u8>(t) {}
00098     };
00099 
00100     template<>
00101     struct integer<7> : public integer_base<u8> {
00102         integer(u8 t = 0) : integer_base<u8>(t) {}
00103     };
00104 
00105     template<>
00106     struct integer<8> : public integer_base<u8> {
00107         integer(u8 t = 0) : integer_base<u8>(t) {}
00108     };
00109 
00110 
00111     //
00112     //  Special Versions for 9 .. 16
00113     //
00114 
00115     template<>
00116     struct integer<9> : public integer_base<u16> {
00117         integer(u16 t = 0) : integer_base<u16>(t) {}
00118     };
00119 
00120     template<>
00121     struct integer<10> : public integer_base<u16> {
00122         integer(u16 t = 0) : integer_base<u16>(t) {}
00123     };
00124 
00125     template<>
00126     struct integer<11> : public integer_base<u16> {
00127         integer(u16 t = 0) : integer_base<u16>(t) {}
00128     };
00129 
00130     template<>
00131     struct integer<12> : public integer_base<u16> {
00132         integer(u16 t = 0) : integer_base<u16>(t) {}
00133     };
00134 
00135     template<>
00136     struct integer<13> : public integer_base<u16> {
00137         integer(u16 t = 0) : integer_base<u16>(t) {}
00138     };
00139 
00140     template<>
00141     struct integer<14> : public integer_base<u16> {
00142         integer(u16 t = 0) : integer_base<u16>(t) {}
00143     };
00144 
00145     template<>
00146     struct integer<15> : public integer_base<u16> {
00147         integer(u16 t = 0) : integer_base<u16>(t) {}
00148     };
00149 
00150     template<>
00151     struct integer<16> : public integer_base<u16> {
00152         integer(u16 t = 0) : integer_base<u16>(t) {}
00153     };
00154 
00155 
00156     //
00157     //  Special Versions for 17 .. 32
00158     //
00159 
00160     template<>
00161     struct integer<17> : public integer_base<u32> {
00162         integer(u32 t = 0) : integer_base<u32>(t) {}
00163     };
00164 
00165     template<>
00166     struct integer<18> : public integer_base<u32> {
00167         integer(u32 t = 0) : integer_base<u32>(t) {}
00168     };
00169 
00170     template<>
00171     struct integer<19> : public integer_base<u32> {
00172         integer(u32 t = 0) : integer_base<u32>(t) {}
00173     };
00174 
00175     template<>
00176     struct integer<20> : public integer_base<u32> {
00177         integer(u32 t = 0) : integer_base<u32>(t) {}
00178     };
00179 
00180     template<>
00181     struct integer<21> : public integer_base<u32> {
00182         integer(u32 t = 0) : integer_base<u32>(t) {}
00183     };
00184 
00185     template<>
00186     struct integer<22> : public integer_base<u32> {
00187         integer(u32 t = 0) : integer_base<u32>(t) {}
00188     };
00189 
00190     template<>
00191     struct integer<23> : public integer_base<u32> {
00192         integer(u32 t = 0) : integer_base<u32>(t) {}
00193     };
00194 
00195     template<>
00196     struct integer<24> : public integer_base<u32> {
00197         integer(u32 t = 0) : integer_base<u32>(t) {}
00198     };
00199 
00200     template<>
00201     struct integer<25> : public integer_base<u32> {
00202         integer(u32 t = 0) : integer_base<u32>(t) {}
00203     };
00204 
00205     template<>
00206     struct integer<26> : public integer_base<u32> {
00207         integer(u32 t = 0) : integer_base<u32>(t) {}
00208     };
00209 
00210     template<>
00211     struct integer<27> : public integer_base<u32> {
00212         integer(u32 t = 0) : integer_base<u32>(t) {}
00213     };
00214 
00215     template<>
00216     struct integer<28> : public integer_base<u32> {
00217         integer(u32 t = 0) : integer_base<u32>(t) {}
00218     };
00219 
00220     template<>
00221     struct integer<29> : public integer_base<u32> {
00222         integer(u32 t = 0) : integer_base<u32>(t) {}
00223     };
00224 
00225     template<>
00226     struct integer<30> : public integer_base<u32> {
00227         integer(u32 t = 0) : integer_base<u32>(t) {}
00228     };
00229 
00230     template<>
00231     struct integer<31> : public integer_base<u32> {
00232         integer(u32 t = 0) : integer_base<u32>(t) {}
00233     };
00234 
00235     template<>
00236     struct integer<32> : public integer_base<u32> {
00237         integer(u32 t = 0) : integer_base<u32>(t) {}
00238     };
00239 
00240 } // namespace shttl
00241 
00242 #endif // SHTTL_INTEGER

Onikiri2に対してTue Jun 18 14:34:21 2013に生成されました。  doxygen 1.4.7