{"id":42,"date":"2011-07-25T08:04:43","date_gmt":"2011-07-25T08:04:43","guid":{"rendered":"http:\/\/192.168.77.7\/wp\/?p=42"},"modified":"2011-09-14T08:29:05","modified_gmt":"2011-09-14T08:29:05","slug":"42","status":"publish","type":"post","link":"https:\/\/tixbay.net\/?p=42","title":{"rendered":"VS bug"},"content":{"rendered":"<pre>\/\/ assign_aTest.cpp : Defines the entry point for the console application.\r\n\/\/\r\n\r\n#include \u201cstdafx.h\u201d\r\n\r\n#include \u201cboost\/spirit.hpp\u201d\r\n#include \u201cboost\/spirit\/actor\/ref_actor.hpp\u201d\r\n\r\nusing namespace boost;\r\nusing namespace boost::spirit;\r\n\r\n#include\r\n\r\nstruct MyParser\r\n: public grammar\r\n{\r\nmutable int m_i;\r\n\r\n\/\/\/ Constructor\r\nMyParser()\r\n{\r\n}\r\n\r\n\/\/\/ Grammar definition\r\ntemplate\r\nstruct definition\r\n{\r\ndefinition(MyParser const&amp; self)\r\n{\r\ntest = (ch_p(L\u2019@'))\r\n[assign_a(self.m_i, 100)];\r\n}\r\n\r\nrule test;\r\n\r\n\/\/ Start rule\r\nrule const&amp; start() const { return test; }\r\n};\r\n};\r\n\r\nstruct MyParser2\r\n: public grammar\r\n{\r\nmutable int m_i;\r\n\r\nstatic const int s_i = 100;\r\n\r\n\/\/\/ Constructor\r\nMyParser2()\r\n{\r\n}\r\n\r\n\/\/\/ Grammar definition\r\ntemplate\r\nstruct definition\r\n{\r\ndefinition(MyParser2 const&amp; self)\r\n{\r\ntest = (ch_p(L\u2019@'))\r\n[assign_a(self.m_i, s_i)];\r\n}\r\n\r\nrule test;\r\n\r\n\/\/ Start rule\r\nrule const&amp; start() const { return test; }\r\n};\r\n};\r\n\r\nint _tmain(int argc, _TCHAR* argv[])\r\n{\r\nstruct MyParser pa;\r\npa.m_i = 0;\r\nparse(L\u201d@\u201d, pa);\r\n\r\nstruct MyParser2 pa2;\r\npa2.m_i = 0;\r\nparse(L\u201d@\u201d, pa2);\r\n\r\nstd::cout&lt;&lt;\"Parse1: \"&lt;&lt;pa.m_i&lt;&lt;std::endl;\r\nstd::cout&lt;&lt;\"Parse2: \"&lt;&lt;pa2.m_i&lt;&lt;std::endl;\r\n\r\nstd::cin.get();\r\nreturn 0;\r\n}\r\n\r\nVC\u5728\u51fd\u6570\u4e2d\u5c06\u5e38\u6570\u503c\u8d4b\u7ed9\u4e00\u4e2a\u5e38\u5f15\u7528\uff0c\u4f1a\u5bfc\u81f4\u51fa\u51fd\u6570\u6709\u6548\u533a\u57df\u540e\u6b64\u5f15\u7528\u7684\u65e0\u6548\uff0c\u4e3a\u4e00\u4e2a\u4e0d\u786e\u5b9a\u503c\u3002\r\n\u66f4\u4e00\u822c\u7684\u6d4b\u8bd5\u4f8b\u7a0b\uff1a\r\n\r\n\/\/ RefTst.cpp : Defines the entry point for the console application.\r\n\/\/\r\n\r\n#include \"stdafx.h\"\r\n#include\r\n#include\r\n\r\nusing namespace std;\r\n\r\nclass A\r\n{\r\nprivate:\r\nconst int&amp; m_i;\r\n\r\npublic:\r\nA(const int&amp; i)\r\n: m_i(i)\r\n{\r\n}\r\n\r\nvoid PrintI()\r\n{\r\ncout&lt;&lt;\"I: \"&lt;&lt;m_i&lt;&lt;endl;\r\nconst int* p = &amp;m_i;\r\ncout&lt;&lt;\"P: \"&lt;&lt;p&lt;&lt;endl;\r\n}\r\n};\r\n\r\nA* GetA()\r\n{\r\nA* pA = new A(123456789);\r\npA-&gt;PrintI();\r\nreturn pA;\r\n}\r\n\r\nvoid Print(A* pA)\r\n{\r\nint i = 54321;\r\n__int64 j = 13328703583;\r\npA-&gt;PrintI();\r\n}\r\n\r\nint _tmain(int argc, _TCHAR* argv[])\r\n{\r\nA* pA = NULL;\r\npA = GetA();\r\npA-&gt;PrintI();\r\nPrint(pA);\r\ndelete pA;\r\ncin.get();\r\nreturn 0;\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/\/ assign_aTest.cpp : Defines the entry  &hellip;<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/tixbay.net\/?p=42\">\u7ee7\u7eed\u9605\u8bfb &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-42","post","type-post","status-publish","format-standard","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/tixbay.net\/index.php?rest_route=\/wp\/v2\/posts\/42","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tixbay.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tixbay.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tixbay.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tixbay.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=42"}],"version-history":[{"count":4,"href":"https:\/\/tixbay.net\/index.php?rest_route=\/wp\/v2\/posts\/42\/revisions"}],"predecessor-version":[{"id":96,"href":"https:\/\/tixbay.net\/index.php?rest_route=\/wp\/v2\/posts\/42\/revisions\/96"}],"wp:attachment":[{"href":"https:\/\/tixbay.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=42"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tixbay.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=42"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tixbay.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}