[ create a new paste ] login | about

Link: http://codepad.org/UvgeTIoC    [ raw code | output | fork ]

C++, pasted on Aug 27:
#include <iostream>
#include <string>
#include <map>

template <typename K, typename V>
bool   exists_in(std::map<K,V> const& haystack, K const& needle) 
{
   return haystack.find(needle) != haystack.end();
}

struct VarInfo
{
  std::string some_info;
};

int main()
{
  std::map<std::string, VarInfo*> my_map;
  VarInfo* p_var = new VarInfo();
  p_var->some_info = "hi";
  const std::string key("key");
  my_map.insert(std::make_pair(key, p_var));

  std::cout << "Key found: " << exists_in(my_map, key) << std::endl;
  return 0;
}


Output:
1
Key found: true


Create a new paste based on this one


Comments: