rttr icon indicating copy to clipboard operation
rttr copied to clipboard

why failed to set_value for a sequential view ?

Open bruceauyeung opened this issue 5 years ago • 0 comments

registration:

registration::class_<std::vector<char*>>("std::vector<char*>")
	.constructor<std::vector<char*>::size_type>()
	(
		policy::ctor::as_raw_ptr
	).constructor<std::vector<char*>::size_type, std::vector<char*>::value_type>()
	(
		policy::ctor::as_raw_ptr,
		default_arguments((char *)NULL)
	);

element assignment


type charPtrArray = type::get_by_name("std::vector<char*>");
auto charPtrArrayInst = charPtrArray.create({ size +1 });  // size is size of a_std_map_view
auto charPtrArrayInstView = charPtrArrayInst.create_sequential_view();
char * aa = "123";
if (!charPtrArrayInstView.set_value(0, aa)) {  // OK here
	ofs << "failed to set first elemement value:"  << std::endl;
	ofs.flush();
}
int i = 1;
for (const auto& item : a_std_map_view)
{
	auto addr = item.second.get_wrapped_value<std::string>().c_str();
	if (!charPtrArrayInstView.set_value(i, addr)) { //FAILED here
		ofs << "failed to set array value: " << addr << std::endl;
		ofs.flush();
	}
	i++;
}

bruceauyeung avatar May 05 '20 09:05 bruceauyeung