mercredi 27 novembre 2019

C++ compile errors when using template in unordered_map

I am trying to use unordered_map in my project. The code related to my problem is

struct Node

struct Node_IB

struct Grid
{
    std::unordered_map< std::bitset<64>, Node> grid;
};

struct Grid_IB
{
    std::unordered_map< std::bitset<64>, Node_IB> grid;
};


template <class T_grid, class T_node>
void func1(T_grid &grid_ptr, T_node node_temp);

int main()
{
       ilevel = 1 ;
       if (ilevel == C_max_level)
    {
        Node_IB node_temp;
        func1(grid_ptr, node_temp);
    }
    else
    {
        Node node_temp;
        func1(grid_ptr, node_temp);
    }
}

template <class T_grid, class T_node>
voidfunc1(T_grid &grid_ptr, T_node node_temp)
{
      std::bitset<64> key = 0;
      grid_ptr.grid.insert(make_pair( key, node_temp));
} 

The error is "error C2664: 'std::_List_iterator>> std::_Hash,_Alloc,false>>::insert(std::_List_const_iterator>>,const std::pair &)': cannot convert argument 1 from 'std::pair,Node>' to 'std::pair &&'"

I am new to code development. Sorry for any confusing information.

Could anyone help me with this?

Thank you

Aucun commentaire:

Enregistrer un commentaire