2011-08-31 71 views
2

我有以下代碼...怎麼看的提升值:在調試模式下unordered_map與VS2010

typedef boost::unordered_map<int, boost::unordered_map<int, float>* > User_item_rating_map; 

正如你所看到的,圖的值是一個指針。我怎樣才能得到地圖中的價值。如果我使用(*(ret[int]))[int],我似乎無法獲得價值。我究竟做錯了什麼?

回答

4

文件AUTOEXP.DAT是告訴Visual Studio如何在調試器中表示數據結構的文件。

,一些描述可以說是相當容易的,像這一個的CSize:

CSize =cx=<cx> cy=<cy> 

但他們也可以很複雜,像這樣的一個位集:

std::bitset<*>{ 
    preview 
    (
     #(
     "[", 
      $c.digits, 
     "](", 
     #array 
     (
      expr : ($c._Array[$i/$c._Bitsperword] >> ($i % $c._Bitsperword)), 
      size : $c.digits 
     ) : [($e & 1),d], 
     ")" 
     ) 
    ) 
    children 
    (
     #array 
     (
      expr : ($c._Array[$i/$c._Bitsperword] >> ($i % $c._Bitsperword)), 
      size : $c.digits 
     ) : (bool)($e & 1)) 
} 

你可以編寫你自己的描述爲boost unordered_map,或者可能有其他人已經爲你做了。看看https://svn.boost.org/trac/boost/ticket/4209(這似乎是你需要的東西)。

1

我有同樣的麻煩,去看看建議修復從Boost Ticket #4209工作,沒有。我可以看到元素的總數,但看不到內容。

因此,可以選擇切換到VS2012,其中有Plug-In,或者投資搞清楚VS2010中的格式並修復現有的建議代碼。

或者,這就是我所做的,而是使用std :: tr1 :: unordered_set/map。 Visual Studio中有一個可視化工具。然後,在調試之後,如果您願意,請切換回升壓。

0

用文本編輯器打開文件autoexp.dat。 你通常會發現它在:

C:\ Program Files文件\微軟的Visual Studio 10.0 \ Common7 \包\調試\ autoexp.dat

下面的代碼添加到部分[展示臺]。這個代碼應該在另一個可視化器的定義之後添加。

;------------------------------------------------------------------------------ 
; boost unordered collections 
;------------------------------------------------------------------------------ 
boost::unordered::unordered_map<*,*,*,*,*>{ 
    preview (
    #(
     "[", 
     $e.table_.size_, 
     "](", 
     #list(
      head: $e.table_.buckets_[$e.table_.bucket_count_].next_, 
      size: $e.table_.size_, 
      next: next_ 
     ) : #(*((std::pair<$T1 const ,$T2>*)&(*(boost::unordered::detail::ptr_node<std::pair<$T1 const ,$T2> > *)(&$e)).value_base_)), 
     ")" 
    )) 
    children(
    #(
     size: ($e.table_.size_), 
     #list(
      head: $e.table_.buckets_[$e.table_.bucket_count_].next_, 
      size: $e.table_.size_, 
      next: next_ 
     ) : #(*((std::pair<$T1 const ,$T2>*)&(*(boost::unordered::detail::ptr_node<std::pair<$T1 const ,$T2> > *)(&$e)).value_base_)), 
    )) 
} 


boost::unordered::unordered_set<*,*,*,*>{ 
    preview (
    #(
     "[", 
     $e.table_.size_, 
     "](", 
     #list(
      head: $e.table_.buckets_[$e.table_.bucket_count_].next_, 
      size: $e.table_.size_, 
      next: next_ 
     ) : #(*(($T1*)&((*(boost::unordered::detail::ptr_node<$T1>*)(&$e)).value_base_))), 
     ")" 
    )) 
    children(
    #(
     size: ($e.table_.size_), 
     #list(
      head: $e.table_.buckets_[$e.table_.bucket_count_].next_, 
      size: $e.table_.size_, 
      next: next_ 
     ) : #(*(($T1*)&((*(boost::unordered::detail::ptr_node<$T1>*)(&$e)).value_base_))), 
    )) 
} 

比如我已經排

;------------------------------------------------------------------------------ 
; std::plus, etc. from <functional> 
;------------------------------------------------------------------------------ 

你的下一個調試會話它應該工作之前添加它。

我用Microsoft Visual Studio 2010 10.0.40219.1 SP1Rel和boost 1.61.0測試了它。