S
Stan Maydan. from NY
Hello,
I am having difficulty mapping Managed C++ hashtable into native C++
map (string to double). Somehow the double value is not mapped properly
(istead of value of 75 something like 10**(-308) is mapped. Keys are
mapped correctly. Can you please help?
// note that Hashtable can not be used in native C++, so it has to be
remapped into map class
std::map<std::string, double> input_loan_double_attributes_map;
String* managed_string_key = NULL;
double __gc* key_value;
/* note that enumerator's initial position is not the first, but it
is before the 1st element
in the collection */
IDictionaryEnumerator __gc *hash_enumerator =
input_loan_double_attributes_hash.GetEnumerator();
while (hash_enumerator->MoveNext())
{
managed_string_key = static_cast<String __gc*> (hash_enumerator->Key);
key_value = static_cast<double __gc*>(hash_enumerator->Value);
Console::WriteLine(S"{0}", (*key_value).ToString()); //PRINTS GARBAGE
input_loan_double_attributes_map.insert(std::make_pair(MC::Utils::convert_String_To_string(managed_string_key),
static_cast<double>(*key_value)));
}
I am having difficulty mapping Managed C++ hashtable into native C++
map (string to double). Somehow the double value is not mapped properly
(istead of value of 75 something like 10**(-308) is mapped. Keys are
mapped correctly. Can you please help?
// note that Hashtable can not be used in native C++, so it has to be
remapped into map class
std::map<std::string, double> input_loan_double_attributes_map;
String* managed_string_key = NULL;
double __gc* key_value;
/* note that enumerator's initial position is not the first, but it
is before the 1st element
in the collection */
IDictionaryEnumerator __gc *hash_enumerator =
input_loan_double_attributes_hash.GetEnumerator();
while (hash_enumerator->MoveNext())
{
managed_string_key = static_cast<String __gc*> (hash_enumerator->Key);
key_value = static_cast<double __gc*>(hash_enumerator->Value);
Console::WriteLine(S"{0}", (*key_value).ToString()); //PRINTS GARBAGE
input_loan_double_attributes_map.insert(std::make_pair(MC::Utils::convert_String_To_string(managed_string_key),
static_cast<double>(*key_value)));
}