VC 2005上的谷歌代码缓存表

时间:2009-02-12 17:44:26

标签: c++ templates visual-studio-2005 stl caching

我正在尝试使用Visual Studio 2005编译google cache-table并仍然存在一个问题:

\ mm \ cache_table.hpp(734):错误C2780:'void std :: _ Destroy(_Ty *)':需要1个参数 - 2个提供
c:\ arquivos de programas \ microsoft visual studio 8 \ vc \ include \ xmemory(58):参见'std :: _ Destroy'的声明
\ mm \ cache_table.hpp(714):同时编译类模板成员函数'void mm :: cache_table< Value,Key,DiscardFunction,HashFunction,KeyEqual,KeyExtract,Allocator>
:: resize(mm :: cache_table<值,钥匙,DiscardFunction,散列函数,KeyEqual,KeyExtract,分配器> :: SIZE_TYPE)'

[
值=的std :: string,
重点=的std :: string,
DiscardFunction = DiscardLog,
散列函数=毫米::散列<的std :: string>中
KeyEqual =标准:: equal_to<的std :: string>中
KeyExtract =毫米::身份和LT;的std :: string>中
分配器=标准::分配器<的std :: string>
]
\ mm \ cache_set.hpp(122):参见类模板实例化'mm :: cache_table< Value,Key,DiscardFunction,HashFunction,KeyEqual,KeyExtract,Allocator>'正在编制中 与
[
值=的std :: string,
重点=的std :: string,
DiscardFunction = DiscardLog,
散列函数=毫米::散列<的std :: string>中
KeyEqual =标准:: equal_to<的std :: string>中
KeyExtract =毫米::身份和LT;的std :: string>中
分配器=标准::分配器<的std :: string>
]
\ cache_table_google.cpp(48):请参阅类模板实例化'mm :: cache_set< Value,HashFunction,KeyEqual,DiscardFunction>'正在编制中 与
[
值=的std :: string,
散列函数=毫米::散列<的std :: string>中
KeyEqual =标准:: equal_to<的std :: string>中
DiscardFunction = DiscardLog
]

标题< xmemory>我找不到带有2个参数的_Destroy模板。

有什么建议吗?


我做了一个发现,可能是在SGI STL中使用了API。我正在进步。


解决方案:

进行更改(对于release cache-table-0.2.tar.gz)

at \ mm \ hash_fun.hpp:
- 包括标题:#include< functional>

at \ mm \ cache_table.hpp:

  • 更改功能

    void resize( size_type size )
    {
        size_t new_size = round_to_power2( size );
        size_t old_size = m_buckets;

        if ( new_size == old_size )
        {
            // Do nothing
            return;
        }
        else if ( new_size < old_size )
        {
            // The new table will be smaller, so there's no need to rehash
            // all the items.
            value_type* new_table;
            new_table = m_allocator.allocate( new_size * ItemSize );

            // Copy the elements that fit into the new table and destroy
            // those that doesn't fit.  Plain old memcpy seems to have much
            // less problems with types than std::copy..
            std::memcpy( new_table, m_table, new_size * ItemSize );

        //_Destroy( iterator( this, m_table + new_size, true ), m_end_it );

            for ( iterator First = iterator( this, m_table + new_size, true ); First != m_end_it; ++First) _Destroy(&First);


            m_allocator.deallocate( m_table, old_size );
            m_table = new_table;
            ...
            ...
            ...


    void clear()
    {
        // Call the destructor for all objects and reinitialize the memory.

        //_Destroy( begin(), end() );

        for ( iterator First = begin(); First != end(); ++First) 
                    _Destroy(&First);

        initialize_memory();
        m_num_elements = 0;
    }


    void erase( iterator first, iterator last )
    {
        m_num_elements -= mm::distance( first, last );
        //_Destroy( first, last );
        for ( ; first != last; ++first) 
                    _Destroy(&last);

        std::uninitialized_fill( first, last, m_empty_value );
    }

0 个答案:

没有答案
相关问题