OSDN Git Service

まずは lexical2/length.hpp をお試し
[roast/roast.git] / roast / include / roast / lexical2 / length.hpp
1 //      Roast+ License
2 /*
3 */
4 #ifndef __SFJP_ROAST__lexical2__length_HPP__
5 #define __SFJP_ROAST__lexical2__length_HPP__
6
7 #include "roast/type_traits/is_derived.hpp"
8
9 namespace roast
10 {
11         namespace lexical
12         {
13                 //////////////////////////////////////////////////////////////////
14                 
15                 struct length_any {};   //      for convertible check by length_of<T>.
16
17                 template <unsigned int LENGTH>
18                 struct length_ : length_any {
19                         static const int length = LENGTH;
20                 };
21                 
22                 typedef length_<0> zero_length;
23                 
24                 //////////////////////////////////
25                 
26                 template <typename U, bool _Valid>
27                 struct _length_of_impl
28                 {
29                         static const int value = U::length;
30                 };
31                 template <typename U>
32                 struct _length_of_impl<U, false>{};
33                 
34                 template <typename T>
35                 struct length_of : public _length_of_impl<
36                         T, type_traits::is_convertible<T,length_any>::value
37                 > {};
38                 
39                 //////////////////////////////////////////////////////////////////
40         }
41 }
42
43 #endif//__SFJP_ROAST__lexical2__length_HPP__