0
我使用JsonCPP 0.6.0,它不支持BOOST_FOREACH
。羅伯特答已使patch使用BOOST_FOREACH
。這裏是差異。我可以在Class之外typedef嗎?
Index: value.h
===================================================================
--- value.h (revision 54283)
+++ value.h (working copy)
@@ -919,6 +919,7 @@
class ValueIteratorBase
{
public:
+ typedef std::bidirectional_iterator_tag iterator_category;
typedef unsigned int size_t;
typedef int difference_type;
typedef ValueIteratorBase SelfType;
@@ -990,6 +991,7 @@
{
friend class Value;
public:
+ typedef const Value value_type;
typedef unsigned int size_t;
typedef int difference_type;
typedef const Value &reference;
@@ -1048,6 +1050,7 @@
{
friend class Value;
public:
+ typedef Value value_type;
typedef unsigned int size_t;
typedef int difference_type;
typedef Value &reference;
所以我需要在json/include/value.h
加3線,但我不希望編輯原始標題的文件,但想在我自己的源代碼添加3行。像這樣:
typedef std::bidirectional_iterator_tag Json::ValueIteratorBase::iterator_category;
當然,我得到了一個錯誤error: typedef name may not be a nested-name-specifier
。 我可以這樣做嗎?
PS。 JsonCPP 0.7.0支持BOOST_FOREACH
。但在我的情況下,我現在無法升級JsonCPP。