デバッグのためだけに、メンバー関数をデバッグ情報を出力するstd::mapラッパー クラスに置き換えることができます。std::map::insert
#include <map>
#include <iostream>
#include <utility>
#include <string>
template<class Key, 
         class Value, 
         class Compare = std::less<Key>, 
         class Allocator = std::allocator<std::pair<const Key, Value>>>
struct wrap_map : std::map<Key, Value, Compare, Allocator>
{
  typedef std::map<Key, Value, Compare, Allocator> base_type;
  std::pair<iterator,bool> insert( const value_type& value )
  {
    std::cout << "Inserted: [" << value.first << "] : " << value.second << std::endl;
    return base_type::insert( value );
  }
};
int main()
{
  wrap_map<int, std::string> mymap;
  mymap.insert( std::make_pair( 10, std::string( "Hello, World!" ) ) );
  std::cout << mymap[10] << std::endl;
}
出力:
Inserted: [10] : Hello, World!
Hello, World!
std::map::insertコードで使用しているの他のオーバーロード、およびstd::map::operator[]それを使用して要素をマップに挿入する場合は、オーバーロードを作成する必要があります。
__LINE__挿入が行われている場所を示すなどのマクロを出力することもできます。
std::mapには仮想デストラクタがないため、マップを動的に割り当てる場合、このアプローチを使用すると、どこでも型名をwrap_map.