锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久婷婷五月综合97色一本一本,亚洲国产成人精品女人久久久 ,99久久精品这里只有精品http://www.shnenglu.com/shifan3/category/3011.htmlEverything is template...zh-cnMon, 19 May 2008 20:19:07 GMTMon, 19 May 2008 20:19:07 GMT60[yc]浼猼ypeofhttp://www.shnenglu.com/shifan3/archive/2006/12/21/16690.htmlshifan3shifan3Thu, 21 Dec 2006 06:29:00 GMThttp://www.shnenglu.com/shifan3/archive/2006/12/21/16690.htmlhttp://www.shnenglu.com/shifan3/comments/16690.htmlhttp://www.shnenglu.com/shifan3/archive/2006/12/21/16690.html#Feedback5http://www.shnenglu.com/shifan3/comments/commentRss/16690.htmlhttp://www.shnenglu.com/shifan3/services/trackbacks/16690.html
鍙戜俊浜? shifan (瀛︿範嫻簯鎶鏈?, 鏉塊潰: C++
鏍?nbsp; 棰? 浼猼ypeof
鍙戜俊绔? 椋樻負姘翠簯闂?(Tue Dec 19 16:38:45 2006), 杞俊
 1 /*
 2 鐢ㄦ爣鍑咰++瀹炵幇typeof鏄笉鍙兘鐨?br> 3 榪欎釜鏄垜鍐欑殑涓涓猘pproached typeof
 4 鎵鏈夐渶瑕佽闈欐佸弽灝勫嚭鏉ョ殑綾誨瀷蹇呴』鍏堢敤DECL_TYPE娉ㄥ唽
 5 妯℃澘濡傛灉浠呬粎甯︽湁1涓弬鏁板彲浠ョ敤DECL_TEMPLATE_1娉ㄥ唽
 6 澶氫釜鍙傛暟鐨勬ā鏉胯繕涓嶆敮鎸併傘?br> 7 涓昏鏄病鎯沖ソ緙栫爜
 8 
 9 鎬誨叡鑳芥敞鍐?4涓被鍨?br>10 鍙互閫氳繃MAX_TYPE_NUMBER璁劇疆
11 
12 鏀寔鐨勬ā鏉垮祵濂楀眰鏁板ぇ綰︿負32 錛?nbsp;log2(MAX_TYPE_NUMBER)
13 MAX_TYPE_NUMBER蹇呴』涓?鐨勬暣嬈℃暟騫?br>14 */
15 namespace my_typeof
16 {
17 
18   const int MAX_TYPE_NUMBER = 64;
19 
20   template <int N>
21   struct dummy
22   {
23     int a[N];
24   };
25 
26 
27   template <int N, typename Arg1>
28   struct select_by_number_1;
29 
30   template <int N>
31   struct select_by_number
32   {
33     typedef typename select_by_number_1<% MAX_TYPE_NUMBER, typename
34 select_by_number</ MAX_TYPE_NUMBER>::type>::type type;
35   };
36 
37 
38   template <typename T>
39   struct number_of
40   {
41     static const int v = sizeof(generic_f(*(T*)0)) / sizeof(int);
42   };
43 
44 
45 #define DECL_TYPE(T, N) \
46   namespace my_typeof{  \
47   template<>\
48   struct select_by_number<N> \
49   {\
50     typedef T type;\
51   };\
52   dummy <N> generic_f(const T&);}
53 
54 
55 #define DECL_TEMPLATE_1(T, N) \
56   namespace my_typeof{        \
57   template<typename Arg1>\
58   struct select_by_number_1<N, Arg1>\
59   {\
60     typedef T<Arg1> type;\
61   };\
62   template <typename Arg1>\
63   dummy<+ number_of<Arg1>::v * MAX_TYPE_NUMBER > generic_f(const T<Arg1>&);}
64 
65 
66 
67 #define TYPE_OF(x) my_typeof::select_by_number<sizeof(my_typeof::generic_f(x)) /
68 sizeof (int)>::type
69 
70 }
71 
72 
73 //sample
74 #include <iostream>
75 #include <vector>
76 #include <list>
77 
78 
79 DECL_TYPE(int1);
80 DECL_TEMPLATE_1(std::vector, 2);
81 DECL_TEMPLATE_1(std::list, 3);
82 DECL_TYPE(double4)
83 
84 using namespace std;
85 int main(intchar*[])
86 {
87   vector<list<vector<list<double> > > > v1;
88   TYPE_OF(v1) v2;
89   v1 = v2;
90   return 0;
91 }
92 
93 


--
You well 鎾掓硶錛乊ou well all 鎾掓硶錛?br>
鈥?鍐呭淇敼:·shifan 浜?Dec 21 14:21:57 淇敼鏈枃鍐呭·[FROM: shifan]
鈥?鏉ユ簮:·椋樻負姘翠簯闂?freecity.cn·[FROM: shifan]


shifan3 2006-12-21 14:29 鍙戣〃璇勮
]]>
[yc]Multi Bit Maskhttp://www.shnenglu.com/shifan3/archive/2006/10/26/14264.htmlshifan3shifan3Thu, 26 Oct 2006 15:37:00 GMThttp://www.shnenglu.com/shifan3/archive/2006/10/26/14264.htmlhttp://www.shnenglu.com/shifan3/comments/14264.htmlhttp://www.shnenglu.com/shifan3/archive/2006/10/26/14264.html#Feedback2http://www.shnenglu.com/shifan3/comments/commentRss/14264.htmlhttp://www.shnenglu.com/shifan3/services/trackbacks/14264.htmlboost鐨刬nteger/integer_mask.hpp浠呬粎鍋氫簡鍗曚釜浣嶇殑bit mask
瑕佸涓綅蹇呴』鍐欏緢澶氶亶high_bit_mask_t
浣跨敤low_bits_mask_t涔熶笉鑳藉畬鍏ㄨВ鍐抽棶棰?br>鎵浠ヨ嚜宸辯敤Typelist鐨勯偅縐嶅啓娉曞啓浜嗕竴涓?/p>

鐢ㄦ硶涓句緥
bit_mask<INT_LIST_2(2, 3)>::value榪斿洖涓涓鹼紝璇ュ肩殑絎?銆?浣嶈緗負1
鍏朵綑浣嶄負0

 

  1 
  2 namespace multi_bit_mask
  3 {
  4     namespace details
  5     {
  6 
  7         template <typename T>
  8         struct get_size
  9         {
 10             enum {size = sizeof(T)}; 
 11         };
 12 
 13         template <int Bit>
 14         struct bit_storage
 15         {
 16             typedef typename bit_storage<Bit - 1>::storage_type storage_type;
 17         };
 18 
 19         //---------platform dependency-----------------------
 20 
 21         typedef unsigned int smallest_storage_type;
 22         typedef unsigned long long largest_storage_type;
 23 
 24         
 25 
 26         template <>
 27         struct bit_storage<0>
 28         {
 29             typedef smallest_storage_type storage_type;
 30         };
 31 
 32         template <>
 33         struct bit_storage<get_size<smallest_storage_type>::size * 8>
 34         {
 35             typedef largest_storage_type storage_type;
 36         };
 37 
 38         //disable the 65th bit
 39         template <>
 40         struct bit_storage<get_size<largest_storage_type>::size * 8>
 41         {
 42             typedef void storage_type;
 43         };
 44         
 45         //---------end of platform dependency----------------
 46 
 47 
 48         template <unsigned int N, typename Next>
 49         struct int_list
 50         {
 51             typedef typename bit_storage<N>::storage_type storage_type;
 52             static const storage_type value = N;
 53             typedef Next next;
 54         };
 55 
 56         struct null_type{};
 57 
 58         template<typename T1, typename T2, bool is_first>
 59         struct selector
 60         {
 61             typedef T1 type;
 62         };
 63 
 64         template<typename T1, typename T2>
 65         struct compare_type
 66         {
 67             const static bool is_larger = sizeof(T1) > sizeof(T2);
 68             typedef typename selector<T1, T2, is_larger>::type large_type;
 69             typedef typename selector<T1, T2, !is_larger>::type small_type;
 70         };
 71 
 72 
 73 
 74         template<typename T1, typename T2>
 75         struct selector<T1, T2, false>
 76         {
 77             typedef T2 type;
 78         };
 79 
 80         template <typename List>
 81         class find_largest_storage
 82         {
 83             typedef typename find_largest_storage<typename List::next>::storage_type T1;
 84             typedef typename bit_storage<List::value>::storage_type T2;
 85         public:
 86             typedef typename compare_type<T1, T2>::large_type storage_type;
 87         };
 88 
 89         template <>
 90         class find_largest_storage<null_type>
 91         {
 92         public:
 93             typedef smallest_storage_type storage_type;
 94         };    
 95 
 96         
 97     }
 98 
 99 
100         
101 
102 
103     template <int N>
104     struct single_bit_mask
105     {
106         typedef typename details::bit_storage<N>::storage_type storage_type;
107         static const storage_type value 
108             = static_cast<storage_type>(single_bit_mask<- 1>::value) * 2;
109     };
110 
111     template <>
112     struct single_bit_mask<0>
113     {
114         typedef details::bit_storage<0>::storage_type storage_type;
115         static const storage_type value = 1;
116     };
117 
118     
119     typedef details::null_type null_type;
120 
121     template <int N, typename Next>
122     struct int_list_t : public details::int_list<N, Next> {};
123 
124     template <typename List>
125     struct bit_mask
126     {
127     public:
128 
129         typedef typename details::find_largest_storage<List>::storage_type storage_type;
130     
131         static const storage_type value 
132             = static_cast<storage_type>(single_bit_mask<List::value>::value) 
133             | static_cast<storage_type>(bit_mask<typename List::next>::value);
134     };
135 
136     template <>
137     struct bit_mask<null_type>
138     {
139         typedef details::bit_storage<0>::storage_type storage_type;
140         static const storage_type value = 0;
141     };
142 
143     
144 
145     
146 
147     #define INT_LIST_1(n1) multi_bit_mask::int_list_t<n1, multi_bit_mask::null_type>
148     #define INT_LIST_2(n1, n2) multi_bit_mask::int_list_t<n1, INT_LIST_1(n2) > 
149     #define INT_LIST_3(n1, n2, n3) multi_bit_mask::int_list_t<n1, INT_LIST_2(n2, n3) > 
150     #define INT_LIST_4(n1, n2, n3, n4) multi_bit_mask::int_list_t<n1, INT_LIST_3(n2, n3, n4) > 
151     #define INT_LIST_5(n1, n2, n3, n4, n5) multi_bit_mask::int_list_t<n1, INT_LIST_4(n2, n3, n4, n5) > 
152     #define INT_LIST_6(n1, n2, n3, n4, n5, n6) multi_bit_mask::int_list_t<n1, INT_LIST_5(n2, n3, n4, n5, n6) > 
153     #define INT_LIST_7(n1, n2, n3, n4, n5, n6, n7) multi_bit_mask::int_list_t<n1, INT_LIST_6(n2, n3, n4, n5, n6, n7) > 
154     #define INT_LIST_8(n1, n2, n3, n4, n5, n6, n7, n8) multi_bit_mask::int_list_t<n1, INT_LIST_7(n2, n3, n4, n5, n6, n7, n8) > 
155     
156 }
157 
158 
159 


sample

#include  < iostream >
#include 
" multi_bit_mask.h "
using   namespace  std;
int  main()
{
    cout 
<<  multi_bit_mask::bit_mask < INT_LIST_1( 1 ) > ::value  <<  endl;
    cout 
<<  multi_bit_mask::bit_mask < INT_LIST_5( 0 1 2 3 4 ) > ::value  <<  endl;
    cout 
<<  multi_bit_mask::bit_mask < INT_LIST_7( 0 1 2 3 4 4 2 ) > ::value  <<  endl;
    


shifan3 2006-10-26 23:37 鍙戣〃璇勮
]]>
[yc]Xpressive綆浠?/title><link>http://www.shnenglu.com/shifan3/archive/2006/07/27/10590.html</link><dc:creator>shifan3</dc:creator><author>shifan3</author><pubDate>Thu, 27 Jul 2006 08:27:00 GMT</pubDate><guid>http://www.shnenglu.com/shifan3/archive/2006/07/27/10590.html</guid><wfw:comment>http://www.shnenglu.com/shifan3/comments/10590.html</wfw:comment><comments>http://www.shnenglu.com/shifan3/archive/2006/07/27/10590.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.shnenglu.com/shifan3/comments/commentRss/10590.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/shifan3/services/trackbacks/10590.html</trackback:ping><description><![CDATA[Xpressive鏄竴涓狢++鐨勬鍒欒〃杈懼紡搴擄紝鐩墠鏄疊oost鐨勫欓夊簱銆?br>Xpressive鍜孊oost.Regex鐨勫尯鍒緢澶с傞鍏堬紝Xpressive鏄竴涓函澶存枃浠剁殑搴擄紝涔熸槸璇達紝鍦ㄤ嬌鐢ㄤ箣鍓嶄笉闇瑕侀鍏堢紪璇戙傚叾嬈★紝Xpressive鏀寔綾諱技浜嶴pirit鐨勯潤鎬佽涔夊畾涔夈?br><br>鎴戜滑鍏堟潵鐪嬩竴涓緥瀛愶細 <p> </p> <div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><span style="COLOR: rgb(0,0,0)">#include </span><span style="COLOR: rgb(0,0,0)"><</span><span style="COLOR: rgb(0,0,0)">iostream</span><span style="COLOR: rgb(0,0,0)">></span><span style="COLOR: rgb(0,0,0)"><br>#include </span><span style="COLOR: rgb(0,0,0)"><</span><span style="COLOR: rgb(0,0,0)">boost</span><span style="COLOR: rgb(0,0,0)">/</span><span style="COLOR: rgb(0,0,0)">xpressive</span><span style="COLOR: rgb(0,0,0)">/</span><span style="COLOR: rgb(0,0,0)">xpressive.hpp</span><span style="COLOR: rgb(0,0,0)">></span><span style="COLOR: rgb(0,0,0)"><br><br></span><span style="COLOR: rgb(0,0,255)">using</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,255)">namespace</span><span style="COLOR: rgb(0,0,0)"> boost::xpressive;<br><br></span><span style="COLOR: rgb(0,0,255)">int</span><span style="COLOR: rgb(0,0,0)"> main()<br>{<br>    std::</span><span style="COLOR: rgb(0,0,255)">string</span><span style="COLOR: rgb(0,0,0)"> hello( </span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">hello world!</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)"> );<br><br>    sregex rex </span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)"> sregex::compile( </span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">(\\w+) (\\w+)!</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)"> );<br>    smatch what;<br><br>    </span><span style="COLOR: rgb(0,0,255)">if</span><span style="COLOR: rgb(0,0,0)">( regex_match( hello, what, rex ) )<br>    {<br>        std::cout </span><span style="COLOR: rgb(0,0,0)"><<</span><span style="COLOR: rgb(0,0,0)"> what[</span><span style="COLOR: rgb(0,0,0)">0</span><span style="COLOR: rgb(0,0,0)">] </span><span style="COLOR: rgb(0,0,0)"><<</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">\n</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">; </span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)"> whole match</span><span style="COLOR: rgb(0,128,0)"><br></span><span style="COLOR: rgb(0,0,0)">        std::cout </span><span style="COLOR: rgb(0,0,0)"><<</span><span style="COLOR: rgb(0,0,0)"> what[</span><span style="COLOR: rgb(0,0,0)">1</span><span style="COLOR: rgb(0,0,0)">] </span><span style="COLOR: rgb(0,0,0)"><<</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">\n</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">; </span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)"> first capture</span><span style="COLOR: rgb(0,128,0)"><br></span><span style="COLOR: rgb(0,0,0)">        std::cout </span><span style="COLOR: rgb(0,0,0)"><<</span><span style="COLOR: rgb(0,0,0)"> what[</span><span style="COLOR: rgb(0,0,0)">2</span><span style="COLOR: rgb(0,0,0)">] </span><span style="COLOR: rgb(0,0,0)"><<</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">\n</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">; </span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)"> second capture</span><span style="COLOR: rgb(0,128,0)"><br></span><span style="COLOR: rgb(0,0,0)">    }<br><br>    </span><span style="COLOR: rgb(0,0,255)">return</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">0</span><span style="COLOR: rgb(0,0,0)">;<br>}</span></div> <p>榪欐槸浣跨敤Xpressive鍔ㄦ佽涔夊畾涔夌殑渚嬪瓙錛屽叾涓璼regex::compile鍑芥暟緙栬瘧涓涓〃紺烘鍒欐枃娉曠殑涓詫紝騫惰繑鍥炰竴涓鍒欏璞regex<br>浣跨敤regex_match鏉ヤ嬌鐢ㄨ繖涓鍒欏璞″尮閰嶄竴涓覆銆傜粨鏋滃偍瀛樺湪what鍐?br>鍏朵腑what[0]榪斿洖鏁翠釜涓詫紝what[1]~what[n]榪斿洖鏂囨硶涓敤浜庢爣璁扮殑閮ㄥ垎(鐢ㄥ皬鎷彿鎷搗鏉ョ殑閮ㄥ垎)<br>鏈鍚庡皢杈撳嚭<br>     hello world!<br>     hello<br>     world</p> <p>濡傛灉鎯沖湪涓涓覆涓煡鎵劇鍚堣鏂囨硶鐨勫瓙涓詫紝鍙互浣跨敤regex_search錛岀敤娉曞拰regex_match涓鏍鳳紝姝ゅ榪樺彲浠ョ敤regex_replace鏉ヨ繘琛屾浛鎹€?br></p> <p> </p> <p><br>闈欐佹枃娉曪細<br>Xpressive闄や簡鍙互鐢╟ompile鏉ュ垎鏋愪竴涓枃娉曚覆涔嬪錛岃繕鍙互鐢ㄧ被浼間簬Spirit鐨勬柟寮忔潵闈欐佺殑鎸囧畾鏂囨硶錛?br></p> <div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: rgb(0,0,0)">sregex re </span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">$</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)">_d </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">.</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> _d </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> _d;</span></div> <p>榪欏皢瀹氫箟涓涓〃紺洪噾棰濈殑涓詫紝鍏朵腑_d琛ㄧず涓涓暟瀛楋紝鐩稿綋浜庝覆 $\d+.\d\d<br>榪欐牱瀹氫箟鏂囨硶灝嗘瘮涔嬪墠鐨勫姩鎬佸畾涔夋洿鍔犻珮鏁堬紝騫朵笖榪樻湁涓涓檮鍔犵殑濂藉錛?br>鍒嗙駭瀹氫箟錛?/p> <div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: rgb(0,0,0)">sregex re </span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">$</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)">_d </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">.</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> _d </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> _d;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>sregex s </span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">(</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> re </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">)</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">;</span></div> <p>榪欐牱s琛ㄧず涓虹敤鎷彿鎷搗鏉ョ殑re<br>閫氳繃鍒嗙駭瀹氫箟錛屾枃娉曡兘琚〃紺虹殑鏇村姞娓呮銆?br>鏇村姞媯掔殑鏄紝鍒嗙駭瀹氫箟榪樺彲浠ュ悜鍚庡紩鐢紝鍥犳鑳藉鍒嗘瀽EBNF</p> <div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: rgb(0,0,0)">sregex group, factor, term, expression;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>group       </span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">(</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> by_ref(expression) </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">)</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>factor      </span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)">_d </span><span style="COLOR: rgb(0,0,0)">|</span><span style="COLOR: rgb(0,0,0)"> group;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>term        </span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)"> factor </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">*</span><span style="COLOR: rgb(0,0,0)">((</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">*</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> factor) </span><span style="COLOR: rgb(0,0,0)">|</span><span style="COLOR: rgb(0,0,0)"> (</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">/</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> factor));<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>expression  </span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)"> term </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">*</span><span style="COLOR: rgb(0,0,0)">((</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> term) </span><span style="COLOR: rgb(0,0,0)">|</span><span style="COLOR: rgb(0,0,0)"> (</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">-</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> term));</span></div> <p>expression瀹氫箟浜嗕竴涓洓鍒欒〃杈懼紡錛屾敞鎰忓叾涓璯roup鐨勫畾涔夈?br>榪欓噷蹇呴』浣跨敤by_ref鏄洜涓篨pressive榛樿鏄兼嫹璐濓紝濡傛灉榪欓噷浣跨敤榛樿鐨勬柟寮忥紝閭d箞浼氶犳垚涓涓棤闄愬驚鐜?br><br><br>Xpressive鍙互鍦ㄨ繖閲屼笅杞?br><a >http://boost-consulting.com/vault/index.php?PHPSESSID=f1d4af8b742cfa7adae7aab373cfc535&direction=0&order=&directory=Strings%20-%20Text%20Processing&PHPSESSID=f1d4af8b742cfa7adae7aab373cfc535</a><br>鍐呮湁璇︾粏鐨勬枃妗?/p> <img src ="http://www.shnenglu.com/shifan3/aggbug/10590.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/shifan3/" target="_blank">shifan3</a> 2006-07-27 16:27 <a href="http://www.shnenglu.com/shifan3/archive/2006/07/27/10590.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>[yc]涔卞簭Policy鎵嬫硶http://www.shnenglu.com/shifan3/archive/2006/07/24/10384.htmlshifan3shifan3Sun, 23 Jul 2006 17:06:00 GMThttp://www.shnenglu.com/shifan3/archive/2006/07/24/10384.htmlhttp://www.shnenglu.com/shifan3/comments/10384.htmlhttp://www.shnenglu.com/shifan3/archive/2006/07/24/10384.html#Feedback8http://www.shnenglu.com/shifan3/comments/commentRss/10384.htmlhttp://www.shnenglu.com/shifan3/services/trackbacks/10384.html鐪嬩簡546@C++@Freecity涔嬪悗錛屽彂瑙夐潪甯告湁鎰忔?鐢辨浜х敓涓浜涙兂娉?/p>

寰堝鏃跺欏啓涓涓被鐨勬椂鍊欙紝闇瑕佸涓ā鐗堝弬鏁幫紝渚嬪涓涓仐浼犵畻娉曠殑綆楁硶綾伙紝闇瑕佷竴涓ā鐗堝弬鏁版潵鎸囧畾浜ら厤鏂瑰紡錛屽彟涓涓ā鐗堝弬鏁版潵鎸囧畾瀛愪唬閫夋嫨鐨勬柟寮忥紝榪樿涓涓弬鏁版潵鎸囧畾鍙樺紓鐨勬柟寮忋傞偅涔堜竴鑸潵璇達紝榪欎釜綾諱細鍐欐垚錛?/p>

template<class T                                                //鎻忚堪闂鐨勪竴涓被
        , class CrossPolicy = AvgCrossPolicy                        //鏉備氦鏂瑰紡
        , class SelectPolicy = DefaultSelectPolicy                //瀛愪唬閫夋嫨鐨勬柟寮?br>        , class VariationPolicy = ReverseVariationPolicy>        //鍙樺紓鏂瑰紡
class Gene
        : private AvgCrossPolicy
        , private SelectPolicy
        , private VariationPolicy
{
        ....
};

榪欐牱鐢ㄦ埛瑕佷嬌鐢ㄨ綾葷殑鏃跺欙紝鍙互鐩存帴鎸囧畾T錛屽氨琛屼簡錛岀劧鑰屽鏋滆鎸囧畾鍙樺紓鏂瑰紡錛岄偅涔堝氨蹇呴』鎶婃墍鏈夌殑鍙傛暟閮芥樉寮忕殑鍐欏嚭鏉ワ紝寰堜笉鏂逛究

546鎻愪緵浜嗕竴縐嶆湁鏁堢殑鏂規硶錛屽彲浠ヨ鎴戜滑浠呬粎鎸囧畾鍙樺紓鍙傛暟錛岃屼笉鐢ㄥ啓鍑哄彟涓や釜Policy
鐢氳嚦鍏佽鎴戜滑浠ヤ換鎰忕殑欏哄簭涔﹀啓鍑犱釜Policy鍙傛暟錛岄兘涓嶄細鏈夐棶棰?/p>

棰勫鐭ヨ瘑:
TypeList
涓涓猅ypeList鏄竴涓被鍨嬬殑瀹瑰櫒
template <typename Type_, typename Next_>
struct TypeList
{
        typedef Type_ Type;
        typedef Next_ Next;
};
榪欏氨鏄竴涓猅ypeList銆?br>鐪嬭繖涓啓娉曪紝鏄笉鏄儚涓涓摼琛紵
棣栧厛瀹氫箟涓涓被鍨嬫潵琛ㄧず閾捐〃灝撅細class NullType{};
鐜板湪涓涓寘鍚簡2涓被鍨嬬殑TypeList灝卞彲浠ュ啓涓猴細
TypeList<T1, TypeList<T2, NullType>  >

濡備綍鍦ㄤ竴涓猅ypeList涓煡鎵句竴涓被鍨嬬殑瀛愮被錛?br>棣栧厛瑕佹湁涓涓狪sDerivedFrom<Base, T>
榪欎釜姣旇緝綆鍗?br>template<class Base, class T>
class IsDerivedFrom
{
        struct large{char a[2];};
        static char pred(Base*);
        static large pred(...);
public:
        enum {Is = sizeof(pred((T*)0)) == sizeof(char)};
};

鐒跺悗FindChild灝卞鏄撲簡
template <class List, class Base>
struct FindChild
{
        template <bool IsChild>
        struct Select
        {
                typedef typename List::Type Type;
        };

        template <>
        struct Select<false>
        {
                typedef typename FindChild<typename List::Next, Base>::Type Type;
        };

        typedef typename Select<IsDerivedFrom<Base, typename List::Type> >::Type Type;
};

褰撶劧榪樿瀵逛竴浜涚壒孌婃儏鍐佃繘琛岀壒鍖栵紝渚嬪NullType
template <class Base>
struct FindChild<NullType, Base>
{
        typedef NullType Type;
};
榪欓噷浣跨敤NullType鏉ヨ〃鏄庢病鎵懼埌

瀹為檯鎿嶄綔錛?br>棣栧厛闇瑕佺粰3涓狿olicy3涓熀綾伙紝鍒嗗埆鍙?br>class AvgCrossPolicyBase{};
class SelectPolicyBase{};
class VariationPolicyBase{};
鍐呭涓虹┖灝辮浜嗭紝榪欐牱涔熸病鏈夎櫄鍑芥暟璋冪敤鐨勫紑閿


鐒跺悗澹版槑涓涓被鏉ヨ〃紺洪粯璁ゆ儏鍐碉細
class DefaultPolicy{};

瀹氫箟涓涓畯
#define TYPELIST_3_N(a, b, c) TypeList<a, TypeList<b, TypeList<c, NullType> > >

涓嬮潰瑕佸啓涓浜涢夋嫨鍣?鐢ㄤ簬鎶婂悎閫傜殑綾誨瀷閫夋嫨鍑烘潵錛屽鏋滄病鎵懼埌錛屽垯瑕佷嬌鐢ㄩ粯璁ょ殑綾誨瀷
template <class List, class Base, class DefaultType>
struct Selector
{
        template <class RetType>
        struct Judge
        {
                typedef RetType Type;
        };
       
        template<>
        struct Judge<NullType>
        {
                typedef DefaultType Type;
        };
        typedef typename Judge<typename FindChild<List, Base>::Type >::Type Type;
};

濂藉暒錛岀幇鍦ㄦ暣涓被鐨勫0鏄庡彲浠ュ啓涓?/p>

template<class T
        , class CrossPolicy_ = DefaultPolicy
        , class SelectPolicy_ = DefaultPolicy
        , class VariationPolicy_ = DefaultPolicy     //鍏跺悗鐨勫弬鏁扮敤鎴蜂笉鍙寚瀹?br>        , class List = TYPELIST_3_N(CrossPolicy_, SelectPolicy_, VariationPolicy_)
        , class CrossPolicy = typename Selector<List, CrossPolicyBase,  AvgCrossPolicy>::Type
        , class SelectPolicy = typename Selector<List,  SelectPolicyBase,  DefaultSelectPolicy>::Type
        , class VariationPolicy = typename Selector<List,  VariationPolicyBase,  ReverseVariationPolicy>::Type
        >
class Gene
        : private CrossPolicy
        , private SelectPolicy
        , private VariationPolicy
{
       
        ....
};


鍏朵腑絎?-7涓弬鏁幫紙List錛孋rossPolicy錛孲electPolicy鍜孷ariationPolicy錛夋槸涓嶇敱鐢ㄦ埛鎸囧畾鐨勶紝浠呬粎鏄負浜嗚搗涓涓埆鍚?br>絎竴涓弬鏁癟蹇呴』鎸囧畾錛岀劧鍚?錛?錛?榪?涓弬鏁板氨鍙互浠繪剰鐨勬敼鍙橀『搴忎簡
渚嬪錛屽彲浠ュ啓Gene<T, DefaultSelectPolicy, AvgCrossPolicy>鑰屼笉浼氭湁浠諱綍闂
濡傛灉涓嶆兂瑕佹渶鍚庨潰鍑犱釜鍙傛暟鐨勮瘽涔熻錛屼絾鏄唬鐮佸氨瑕佺◢寰暱涓鐐?br>鑰屼笖鏈濂藉湪綾婚噷闈㈣繘琛?涓猼ypedef
typedef typename Selector<List, CrossPolicyBase,  AvgCrossPolicy>::Type CrossPolicy;
絳夛紝浠ヤ究鍦ㄥ疄鐜扮殑鏃跺欎嬌鐢?/p>

shifan3 2006-07-24 01:06 鍙戣〃璇勮
]]>
[yc]鑷繁瀹炵幇Lambda錛堢浜岄儴鍒嗭級http://www.shnenglu.com/shifan3/archive/2006/07/15/10099.htmlshifan3shifan3Sat, 15 Jul 2006 07:32:00 GMThttp://www.shnenglu.com/shifan3/archive/2006/07/15/10099.htmlhttp://www.shnenglu.com/shifan3/comments/10099.htmlhttp://www.shnenglu.com/shifan3/archive/2006/07/15/10099.html#Feedback0http://www.shnenglu.com/shifan3/comments/commentRss/10099.htmlhttp://www.shnenglu.com/shifan3/services/trackbacks/10099.html闃呰鍏ㄦ枃

shifan3 2006-07-15 15:32 鍙戣〃璇勮
]]>
[yc]鑷繁瀹炵幇Lambdahttp://www.shnenglu.com/shifan3/archive/2006/06/09/8334.htmlshifan3shifan3Fri, 09 Jun 2006 05:23:00 GMThttp://www.shnenglu.com/shifan3/archive/2006/06/09/8334.htmlhttp://www.shnenglu.com/shifan3/comments/8334.htmlhttp://www.shnenglu.com/shifan3/archive/2006/06/09/8334.html#Feedback6http://www.shnenglu.com/shifan3/comments/commentRss/8334.htmlhttp://www.shnenglu.com/shifan3/services/trackbacks/8334.html闃呰鍏ㄦ枃

shifan3 2006-06-09 13:23 鍙戣〃璇勮
]]>
[yc]boost::spirit鍒濅綋楠?/title><link>http://www.shnenglu.com/shifan3/archive/2005/12/18/1857.html</link><dc:creator>shifan3</dc:creator><author>shifan3</author><pubDate>Sun, 18 Dec 2005 04:02:00 GMT</pubDate><guid>http://www.shnenglu.com/shifan3/archive/2005/12/18/1857.html</guid><wfw:comment>http://www.shnenglu.com/shifan3/comments/1857.html</wfw:comment><comments>http://www.shnenglu.com/shifan3/archive/2005/12/18/1857.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.shnenglu.com/shifan3/comments/commentRss/1857.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/shifan3/services/trackbacks/1857.html</trackback:ping><description><![CDATA[<p><font face="Courier New">    鏈榪戜負浜嗚В鏋怱QL璇硶錛屾鐫璇曚竴璇曠殑蹇冩佸幓緲諱簡緲籦oost鐨剆pirit搴擄紝鍥犱負璇ュ簱鐨勬枃妗g殑綆浠嬮噷鍐欑潃LL parser framework  represents parsers directly as EBNF grammars in inlined C++銆傜湅鐫framework榪欎釜璇嶈嚜鐒惰寰楄繖涓簱寰堢墰B錛岃瘯鐢ㄤ簡涓涓嬫灉鐒跺姝ゃ?br>    鎵璋揈BNF鍗蟲墿灞曞反鍏嬫柉鑼冨紡錛屾槸涓縐嶆弿榪癈ontext-Free Language鐨勬枃娉曘傚湪鐩墠甯歌鐨勯潪鑷劧璇█涓紝澶ч儴鍒嗛兘鍙互鐢‥BNF琛ㄧず銆備緥濡傦細<br><span id="zd5trdp" class=identifier>      group  </span><span id="l55n553" class=special>::=</span><span id="tbz3551" class=literal>'('</span><span id="jf3zr1r" class=identifier><span id="5j35tnr" class=identifier>exp </span></span></font><font face="Courier New"><span id="v3dvdj3" class=literal>')'<br></span>      <span id="fd3lx35" class=identifier>factor </span><span id="51z5d35" class=special>::=</span><span id="5r5pb3z" class=identifier>integer</span><span id="5zvnftn" class=special>|</span></font> <font face="Courier New"><span id="jl5v3v5" class=identifier>group<br></span>      <span id="5n35h5b" class=identifier>term   </span><span id="13hpvnd" class=special>::=</span><span id="btj3rj3" class=identifier>factor</span><span id="jlb5p13" class=special>((</span><span id="l3h355n" class=literal>'*'</span><span id="33bz5lf" class=identifier>factor</span><span id="5dbxd5h" class=special>)</span><span id="15tn55x" class=special>|</span><span id="1l5p315" class=special>(</span><span id="vp3n53d" class=literal>'/'</span><span id="t3np3nl" class=identifier>factor</span></font> <font face="Courier New"><span id="jftp55f" class=special>))*<br></span>      <span id="1tbvbdt" class=identifier>exp    </span><span id="j5p3dnn" class=special>::=</span><span id="bx5tzhp" class=identifier>term</span><span id="vxd33jh" class=special>((</span><span id="jvnjpff" class=literal>'+'</span><span id="5xlntrj" class=identifier>term</span><span id="hlfrl3r" class=special>)</span><span id="bdp5xjz" class=special>|</span><span id="nzt3thx" class=special>(</span><span id="rd55jh5" class=literal>'-'</span><span id="p3jlpf3" class=identifier>term</span></font> <span id="rb33xhn" class=special><font face="Courier New">))*<br>榪欐槸涓涓暣鏁拌〃杈懼紡鐨凟BNF銆傝孌墊弿榪扮敤spirit鍦–++涓殑瀹炵幇鍒欐槸錛?br>   </font> </span></p> <div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><font face="Courier New">   <img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: rgb(0,0,0)">rule</span><span style="COLOR: rgb(0,0,0)"><></span><span style="COLOR: rgb(0,0,0)"> group, factor, term, exp;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>   group  </span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">(</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> exp </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">)</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>   factor </span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)"> int_p </span><span style="COLOR: rgb(0,0,0)">|</span><span style="COLOR: rgb(0,0,0)"> group;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>   term   </span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)"> factor </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">*</span><span style="COLOR: rgb(0,0,0)">((</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">*</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> factor) </span><span style="COLOR: rgb(0,0,0)">|</span><span style="COLOR: rgb(0,0,0)"> (</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">/</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> factor));<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>   exp    </span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)"> term </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">*</span><span style="COLOR: rgb(0,0,0)">((</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> term) </span><span style="COLOR: rgb(0,0,0)">|</span><span style="COLOR: rgb(0,0,0)"> (</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">-</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> term));<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span></font> </div> <p><font face="Courier New">榪欓噷浣跨敤=浠f浛::=, 鐢?gt;>浠f浛絀烘牸榪炴帴銆傚茍涓旂敱浜嶤++璇硶鎵闄愶紝EBNF涓悗緗殑*鍦╯pirit涓敼涓哄墠緗?br>絳夊紡宸﹁竟鐨勫崟璇嶈縐頒負涓涓猺ule錛岀瓑寮忓彸杈逛負rule鐨勫畾涔夈傛垜浠彲浠ョ湅鍑轟竴涓猤roup鏄竴涓猠xp鍔犱笂涓瀵規嫭鍙鳳紝涓涓猣actor鏄竴涓暣鏁版垨鑰呬竴涓猤roup,涓涓猼erm鏄竴涓垨澶氫釜factor鐢?/榪炴帴錛屼竴涓猠xp鏄竴涓垨澶氫釜term鐢?-榪炴帴銆傚浜庢渶欏剁鐨別xp鍙互鎹璇嗗埆鍑轟互涓嬭〃杈懼紡<br></font><font face="Courier New"><span id="vx3j55b" class=number>   </span> </font></p> <div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><font face="Courier New">   <img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: rgb(0,0,0)">12345</span><span style="COLOR: rgb(0,0,0)"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>   </span><span style="COLOR: rgb(0,0,0)">-</span><span style="COLOR: rgb(0,0,0)">12345</span><span style="COLOR: rgb(0,0,0)"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>   </span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)">12345</span><span style="COLOR: rgb(0,0,0)"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>   </span><span style="COLOR: rgb(0,0,0)">1</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">2</span><span style="COLOR: rgb(0,0,0)"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>   </span><span style="COLOR: rgb(0,0,0)">1</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">*</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">2</span><span style="COLOR: rgb(0,0,0)"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>   </span><span style="COLOR: rgb(0,0,0)">1</span><span style="COLOR: rgb(0,0,0)">/</span><span style="COLOR: rgb(0,0,0)">2</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">3</span><span style="COLOR: rgb(0,0,0)">/</span><span style="COLOR: rgb(0,0,0)">4</span><span style="COLOR: rgb(0,0,0)"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>   </span><span style="COLOR: rgb(0,0,0)">1</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">2</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">3</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">4</span><span style="COLOR: rgb(0,0,0)"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>   </span><span style="COLOR: rgb(0,0,0)">1</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">*</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">2</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">*</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">3</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">*</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">4</span><span style="COLOR: rgb(0,0,0)"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>   (</span><span style="COLOR: rgb(0,0,0)">1</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">2</span><span style="COLOR: rgb(0,0,0)">) </span><span style="COLOR: rgb(0,0,0)">*</span><span style="COLOR: rgb(0,0,0)"> (</span><span style="COLOR: rgb(0,0,0)">3</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">4</span><span style="COLOR: rgb(0,0,0)">)<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>   (</span><span style="COLOR: rgb(0,0,0)">-</span><span style="COLOR: rgb(0,0,0)">1</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">2</span><span style="COLOR: rgb(0,0,0)">) </span><span style="COLOR: rgb(0,0,0)">*</span><span style="COLOR: rgb(0,0,0)"> (</span><span style="COLOR: rgb(0,0,0)">3</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">-</span><span style="COLOR: rgb(0,0,0)">4</span><span style="COLOR: rgb(0,0,0)">)<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>   </span><span style="COLOR: rgb(0,0,0)">1</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)"> ((</span><span style="COLOR: rgb(0,0,0)">6</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">*</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">200</span><span style="COLOR: rgb(0,0,0)">) </span><span style="COLOR: rgb(0,0,0)">-</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">20</span><span style="COLOR: rgb(0,0,0)">) </span><span style="COLOR: rgb(0,0,0)">/</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">6</span><span style="COLOR: rgb(0,0,0)"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>   (</span><span style="COLOR: rgb(0,0,0)">1</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)"> (</span><span style="COLOR: rgb(0,0,0)">2</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)"> (</span><span style="COLOR: rgb(0,0,0)">3</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)"> (</span><span style="COLOR: rgb(0,0,0)">4</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">5</span><span style="COLOR: rgb(0,0,0)">))))<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span></font> </div> <p><font face="Courier New">    寰楀埌涓涓猺ule涔嬪悗錛屾垜浠氨鍙互鐢?/font> <span id="zb35fnn" class=identifier><font face="Courier New">parse鍑芥暟瀵逛竴涓覆榪涜璇嗗埆浜嗐備緥濡?br>         </font> </span></p> <div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><span style="COLOR: rgb(0,0,0)"><font face="Courier New">         parse(</font> </span><span style="COLOR: rgb(0,0,0)"><font face="Courier New">"</font> </span><span style="COLOR: rgb(0,0,0)"><font face="Courier New">(1 + (2 + (3 + (4 + 5))))</font> </span><span style="COLOR: rgb(0,0,0)"><font face="Courier New">"</font> </span><span style="COLOR: rgb(0,0,0)"><font face="Courier New">, exp);</font> </span></div> <p><font face="Courier New"><br>璇ュ嚱鏁拌繑鍥炰竴涓粨鏋刾arse_info錛屽彲浠ラ氳繃璁塊棶鍏朵腑鐨刦ull鎴愬憳鏉ュ垽鏂槸鍚︽垚鍔熻瘑鍒紝涔熷彲浠ヨ闂畇top鎴愬憳鏉ヨ幏鐭ュけ璐ョ殑浣嶇疆銆傝繖閲岃鐗瑰埆鎻愪竴鐐癸紝鍏充簬鍚勪釜絎﹀彿涔嬮棿鐨勭┖鏍鹼紝spirit鐨勬枃妗g殑姝f枃璇寸殑鏄粰parse鍐嶄紶涓涓弬鏁皊pace_p錛岄氱煡parse璺寵繃鎵鏈夌殑絀烘牸錛岀劧鑰屽湪FAQ涓張鎻愬埌錛屽鏋滀嬌鐢ㄤ互涓婃柟娉曞畾涔塺ule錛岀涓変釜鍙傛暟浼爏pace_p浼氬け璐ャ傚師鍥犳槸浣跨敤rule榛樿瀹氫箟鐨勮鍒欒縐頒負character level parsing錛屽嵆瀛楃綰у埆瑙f瀽錛岃宲arse鐨勭3涓弬鏁頒粎閫傜敤浜巔hrase level parsing錛屽嵆璇硶綰у埆瑙f瀽銆傝浣跨敤絎?涓弬鏁板彲浠ユ湁鍑犵鏂規硶銆?br>      1銆傚湪parse鐨勭浜屼釜鍙傛暟鐩存帴浼犲叆涓涓狤BNF琛ㄨ揪寮忥紝涓嶅垱寤簉ule瀵硅薄銆?br>         <span id="5rt555j" class=identifier></span></font> </p> <div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><span style="COLOR: rgb(0,0,0)"><font face="Courier New">            parse(</font> </span><span style="COLOR: rgb(0,0,0)"><font face="Courier New">"</font> </span><span style="COLOR: rgb(0,0,0)"><font face="Courier New">hello world</font> </span><span style="COLOR: rgb(0,0,0)"><font face="Courier New">"</font> </span><span style="COLOR: rgb(0,0,0)"><font face="Courier New">, </font> </span><span style="COLOR: rgb(0,0,0)"><font face="Courier New">*</font> </span><span style="COLOR: rgb(0,0,0)"><font face="Courier New">anychar_p, space_p);  </font> </span></div> <p><font face="Courier New"><span id="jr5bxxn" class=special><br>      2銆備互rule<phrase_scanner_t>鍒涘緩rule銆?br>         </span> </font></p> <div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><span style="COLOR: rgb(0,0,0)"><font face="Courier New">            rule</font> </span><span style="COLOR: rgb(0,0,0)"><font face="Courier New"><</font> </span><span style="COLOR: rgb(0,0,0)"><font face="Courier New">phrase_scanner_t</font> </span><span style="COLOR: rgb(0,0,0)"><font face="Courier New">></font> </span><span style="COLOR: rgb(0,0,0)"><font face="Courier New"> exp; </font> </span></div> <p><font face="Courier New">娉ㄦ剰铏界劧鍙互鐢ㄨ繖涓や釜鍔炴硶灞忚斀絀烘牸錛屼絾鏄繖鏍峰彲鑳藉畬鍏ㄦ敼鍙楨BNF鏂囨硶鐨勮涔夛紝灝ゅ叾鏄湪璇█鏈韓闇瑕佽瘑鍒┖鏍肩殑鏃跺欍傚浜庤繖縐嶆儏鍐碉紝鍙互涓嶄嬌鐢ㄧ涓変釜鍙傛暟錛屽茍鍦ㄩ渶瑕佸嚭鐜扮┖鏍肩殑鍦版柟鍔犱笂space_p,鎴栬?space_p鍙?space_p錛屽叾涓?鍜?鍒嗗埆琛ㄧず鍚庨潰鐨勭鍙瘋繛緇嚭鐜頒竴嬈′互涓婂拰0嬈′互涓娿備緥濡備竴涓互絀烘牸鍒嗛殧鐨勬暣鏁板垪琛ㄥ彲浠ュ啓鎴恑nt_p >> *(+space_p >> int_p)<br>   濡備笂浣跨敤parse鍙互璇嗗埆涓涓覆錛屼絾騫朵笉鑳藉仛鏇村鐨勬搷浣滐紝渚嬪灝嗚娉曢噷鐨勫悇涓垚鍒嗘彁鍙栧嚭鏉ャ傚浜庤繖鏍風殑闇姹傦紝鍙互閫氳繃actor瀹炵幇銆備笅闈㈡槸浣跨敤actor鐨勪竴涓畝鍗曚緥瀛?br>   <span id="hfv333b" class=keyword></span></font> </p> <div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><font face="Courier New"><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>   <span style="COLOR: rgb(0,0,255)">bool</span><span style="COLOR: rgb(0,0,0)"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>   parse_numbers(</span><span style="COLOR: rgb(0,0,255)">char</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,255)">const</span><span style="COLOR: rgb(0,0,0)">*</span><span style="COLOR: rgb(0,0,0)"> str, vector</span><span style="COLOR: rgb(0,0,0)"><</span><span style="COLOR: rgb(0,0,255)">double</span><span style="COLOR: rgb(0,0,0)">>&</span><span style="COLOR: rgb(0,0,0)"> v)<br><img id=Codehighlighter1_61_247_Open_Image onclick="this.style.display='none'; Codehighlighter1_61_247_Open_Text.style.display='none'; Codehighlighter1_61_247_Closed_Image.style.display='inline'; Codehighlighter1_61_247_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_61_247_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_61_247_Closed_Text.style.display='none'; Codehighlighter1_61_247_Open_Image.style.display='inline'; Codehighlighter1_61_247_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align=top>   </span><span id=Codehighlighter1_61_247_Closed_Text style="BORDER-RIGHT: rgb(128,128,128) 1px solid; BORDER-TOP: rgb(128,128,128) 1px solid; DISPLAY: none; BORDER-LEFT: rgb(128,128,128) 1px solid; BORDER-BOTTOM: rgb(128,128,128) 1px solid; BACKGROUND-COLOR: rgb(255,255,255)"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_61_247_Open_Text><span style="COLOR: rgb(0,0,0)">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>      </span><span style="COLOR: rgb(0,0,255)">return</span><span style="COLOR: rgb(0,0,0)"> parse(str,<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>   </span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">  Begin grammar</span><span style="COLOR: rgb(0,128,0)"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: rgb(0,0,0)">      (<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>         real_p[push_back_a(v)] </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">*</span><span style="COLOR: rgb(0,0,0)">(</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)">,</span><span style="COLOR: rgb(0,0,0)">'</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> real_p[push_back_a(v)])<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>      )<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>      ,<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>      </span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">  End grammar</span><span style="COLOR: rgb(0,128,0)"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: rgb(0,0,0)">      space_p).full;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>   }</span></span><span style="COLOR: rgb(0,0,0)"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span></font> </div> <p><font face="Courier New">娉ㄦ剰鍒?span class=identifier>real_p鍚庨潰鐨刐]錛屼腑鎷彿閲岄潰鏄竴涓豢鍑芥暟錛堝嚱鏁版寚閽堟垨鑰呭嚱鏁板璞★級錛岃浠垮嚱鏁板叿鏈夊涓嬭皟鐢ㄥ瀷鍒?br>   </span></font> </p> <div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><font face="Courier New">   <img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: rgb(0,0,255)">void</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,255)">operator</span><span style="COLOR: rgb(0,0,0)">()(IterT first, IterT last) </span><span style="COLOR: rgb(0,0,255)">const</span><span style="COLOR: rgb(0,0,0)">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>   </span><span style="COLOR: rgb(0,0,255)">void</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,255)">operator</span><span style="COLOR: rgb(0,0,0)">()(NumT val) </span><span style="COLOR: rgb(0,0,255)">const</span><span style="COLOR: rgb(0,0,0)">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top>   </span><span style="COLOR: rgb(0,0,255)">void</span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,255)">operator</span><span style="COLOR: rgb(0,0,0)">()(CharT ch) </span><span style="COLOR: rgb(0,0,255)">const</span><span style="COLOR: rgb(0,0,0)">;</span></font> </div> <p><span id="xn55555" class=special><span id="3lfnppn" class=special><span id="33l5vnb" class=special><font face="Courier New"><br>涓鏃pase鍙戠幇浜嗗尮閰?span class=identifier>real_p鐨勫瓙涓詫紝灝變細璋冪敤璇unctor銆備笉鍚岀殑rule鍙兘浼氬搴斾笉鍚岀殑璋冪敤鍨嬪埆銆?/span><br>絎竴涓瀷鍒拡瀵逛竴鑸鍒欙紝first鍜宭ast涓轟袱涓寚鍚戝瓧絎︾殑榪唬鍣紙涓鑸負char*錛?鍖歸厤鐨勫瓙涓蹭負[first, last)<br>絎簩涓瀷鍒拡瀵規暟瀛楀瀷瑙勫垯錛屽real_p鍜宨nt_p, 鍙傛暟val鏄竴涓暟瀛楃被鍨嬨?br>絎笁涓у埆閽堝鍗曞瓧絎﹀瀷瑙勫垯錛屽space_p, 鍙傛暟ch鏄竴涓瓧絎︾被鍨嬨?br><span id="3d5frzp" class=identifier>real_p</span><span id="jzxh515" class=special>[</span><span id="tth3515" class=identifier>push_back_a</span><span id="rrt53j5" class=special>(</span><span id="35dxbzh" class=identifier>v</span><span id="3tfbv5z" class=special>)]涓殑push_back_a鏄竴涓猻pirit宸茬粡瀹氫箟濂界殑functor錛屽畠浼氬皢鍖歸厤濂界殑鍐呭渚濈収鍖歸厤鍒扮殑鏃墮棿欏哄簭璋冪敤v鐨刾ush_back鍑芥暟鍔犲叆鍒皏涓?br><br>   鍒版spirit鐨勫父鐢ㄥ姛鑳藉氨閮戒粙緇嶅畬浜嗐傝璇︾粏娣卞叆浜嗚В鍙互鍙傝僺pirit鐨勬枃妗c?br><br>鏈鍚庡湪棰樹竴涓敞鎰忚鐐廣俿pirit鐨勫悇縐岴BNF榪炴帴閮芥槸鎸囬拡榪炴帴錛屽洜姝ゆ墠鑳藉湪expression琚祴鍊煎墠灝卞湪group鐨勫畾涔夐噷闈嬌鐢ㄣ傛墍浠ュ湪浣跨敤EBNF鐨勬椂鍊欎竴瀹氳灝忓績涓嶈灝嗗眬閮ㄥ彉閲忕殑rule鎻愪緵緇欏叏灞鎴栬呯被鎴愬憳鍙橀噺浣跨敤錛屼緥濡傦細<br>   </span></font> </span></span></span></p> <div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><font face="Courier New">   <img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: rgb(0,0,255)">class</span><span style="COLOR: rgb(0,0,0)"> A<br><img id=Codehighlighter1_11_166_Open_Image onclick="this.style.display='none'; Codehighlighter1_11_166_Open_Text.style.display='none'; Codehighlighter1_11_166_Closed_Image.style.display='inline'; Codehighlighter1_11_166_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_11_166_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_11_166_Closed_Text.style.display='none'; Codehighlighter1_11_166_Open_Image.style.display='inline'; Codehighlighter1_11_166_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align=top>   </span><span id=Codehighlighter1_11_166_Closed_Text style="BORDER-RIGHT: rgb(128,128,128) 1px solid; BORDER-TOP: rgb(128,128,128) 1px solid; DISPLAY: none; BORDER-LEFT: rgb(128,128,128) 1px solid; BORDER-BOTTOM: rgb(128,128,128) 1px solid; BACKGROUND-COLOR: rgb(255,255,255)"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_11_166_Open_Text><span style="COLOR: rgb(0,0,0)">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>      rule</span><span style="COLOR: rgb(0,0,0)"><></span><span style="COLOR: rgb(0,0,0)"> s;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>      A()<br><img id=Codehighlighter1_45_161_Open_Image onclick="this.style.display='none'; Codehighlighter1_45_161_Open_Text.style.display='none'; Codehighlighter1_45_161_Closed_Image.style.display='inline'; Codehighlighter1_45_161_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_45_161_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_45_161_Closed_Text.style.display='none'; Codehighlighter1_45_161_Open_Image.style.display='inline'; Codehighlighter1_45_161_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>      </span><span id=Codehighlighter1_45_161_Closed_Text style="BORDER-RIGHT: rgb(128,128,128) 1px solid; BORDER-TOP: rgb(128,128,128) 1px solid; DISPLAY: none; BORDER-LEFT: rgb(128,128,128) 1px solid; BORDER-BOTTOM: rgb(128,128,128) 1px solid; BACKGROUND-COLOR: rgb(255,255,255)"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_45_161_Open_Text><span style="COLOR: rgb(0,0,0)">{<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>         rule</span><span style="COLOR: rgb(0,0,0)"><></span><span style="COLOR: rgb(0,0,0)"> r </span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)"> int_p </span><span style="COLOR: rgb(0,0,0)">|</span><span style="COLOR: rgb(0,0,0)"> hex_p;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>         s </span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)"> r </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> </span><span style="COLOR: rgb(0,0,0)">*</span><span style="COLOR: rgb(0,0,0)">(</span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)">space_p </span><span style="COLOR: rgb(0,0,0)">>></span><span style="COLOR: rgb(0,0,0)"> r); </span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">error, r destructed after return </span><span style="COLOR: rgb(0,128,0)"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top></span><span style="COLOR: rgb(0,0,0)">      }</span></span><span style="COLOR: rgb(0,0,0)"><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>   }</span></span><span style="COLOR: rgb(0,0,0)">;<br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top></span></font> </div> <p><span id="33555lr" class=special><span id="t3b53zz" class=identifier><font face="Courier New"><span id="ljv3ddt" class=special><span id="5h3jv5x" class=identifier><span id="n3v35j5" class=special><span id="3zttd5p" class=special><span id="hpbn3r5" class=special><span id="fnzl3n5" class=special>濡傛灉鐪熸兂浣跨敤灞閮ㄤ綔鐢ㄥ煙錛屽彲浠ュ湪灞閮ㄧ殑rule鍓嶉潰鍔犱笂static.</span> </span></span></span></span></span></font></span></span></p> <img src ="http://www.shnenglu.com/shifan3/aggbug/1857.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/shifan3/" target="_blank">shifan3</a> 2005-12-18 12:02 <a href="http://www.shnenglu.com/shifan3/archive/2005/12/18/1857.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://www.shnenglu.com/" title="精品视频久久久久">精品视频久久久久</a> <div class="friend-links"> </div> </div> </footer> <a href="http://www.moonlong.cn" target="_blank">av色综合久久天堂av色综合在 </a>| <a href="http://www.bao00long.cn" target="_blank">97视频久久久</a>| <a href="http://www.17779.com.cn" target="_blank">久久精品国产精品青草</a>| <a href="http://www.ycqdzgov.cn" target="_blank">亚洲∧v久久久无码精品</a>| <a href="http://www.sanbaotong.cn" target="_blank">久久国产劲爆AV内射—百度</a>| <a href="http://www.daemontools.org.cn" target="_blank">国产成人香蕉久久久久</a>| <a href="http://www.lyrisme.cn" target="_blank">国产成人久久777777</a>| <a href="http://www.w-sh.cn" target="_blank">国产精品九九久久免费视频</a>| <a href="http://www.tianyicpa.com.cn" target="_blank">久久最新精品国产</a>| <a href="http://www.jiudexn.cn" target="_blank">国产精品丝袜久久久久久不卡</a>| <a href="http://www.bilili.com.cn" target="_blank">狠狠色丁香久久综合婷婷</a>| <a href="http://www.xibeiguangdian.cn" target="_blank">精品999久久久久久中文字幕 </a>| <a href="http://www.taokecai.cn" target="_blank">色综合久久久久综合体桃花网 </a>| <a href="http://www.sylucq.cn" target="_blank">久久精品国产亚洲麻豆</a>| <a href="http://www.ksjhyt.cn" target="_blank">久久精品视频免费</a>| <a href="http://www.bibi81.cn" target="_blank">久久精品国产福利国产琪琪</a>| <a href="http://www.gz2378.cn" target="_blank">久久伊人五月天论坛</a>| <a href="http://www.vnxz.cn" target="_blank">久久久www免费人成精品</a>| <a href="http://www.sehinix.cn" target="_blank">亚洲精品乱码久久久久久</a>| <a href="http://www.xinwenzaocan.org.cn" target="_blank">久久久久亚洲精品无码蜜桃</a>| <a href="http://www.tuandang.cn" target="_blank">久久亚洲国产欧洲精品一</a>| <a href="http://www.mrksl.cn" target="_blank">久久精品国产99国产精品</a>| <a href="http://www.r7c1.cn" target="_blank">99久久99久久精品国产片果冻</a>| <a href="http://www.swfun.com.cn" target="_blank">影音先锋女人AV鲁色资源网久久 </a>| <a href="http://www.task5.cn" target="_blank">久久国产劲爆AV内射—百度</a>| <a href="http://www.sanghuan.cn" target="_blank">婷婷久久久亚洲欧洲日产国码AV</a>| <a href="http://www.0546bbs.cn" target="_blank">国产美女久久精品香蕉69</a>| <a href="http://www.rjlmd.cn" target="_blank">国产午夜福利精品久久</a>| <a href="http://www.tmnv.cn" target="_blank">欧美一区二区久久精品</a>| <a href="http://www.cyjeans.com.cn" target="_blank">久久综合给久久狠狠97色</a>| <a href="http://www.iaro.cn" target="_blank">久久国产精品波多野结衣AV</a>| <a href="http://www.kkha.cn" target="_blank">日本WV一本一道久久香蕉</a>| <a href="http://www.ds361.cn" target="_blank">久久99久久99小草精品免视看 </a>| <a href="http://www.hilxb.cn" target="_blank">久久综合丁香激情久久</a>| <a href="http://www.jkzyzj.cn" target="_blank">色婷婷综合久久久久中文字幕</a>| <a href="http://www.zheibvgsz.cn" target="_blank">亚洲va国产va天堂va久久</a>| <a href="http://www.gmlu.cn" target="_blank">国产午夜精品理论片久久</a>| <a href="http://www.sh-tx.cn" target="_blank">亚洲av伊人久久综合密臀性色</a>| <a href="http://www.uhqw.cn" target="_blank">精品久久久久久无码国产</a>| <a href="http://www.tvhhm.cn" target="_blank">亚洲AV无码久久精品成人</a>| <a href="http://www.cn0513.cn" target="_blank">国产精品xxxx国产喷水亚洲国产精品无码久久一区 </a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>