phylanx icon indicating copy to clipboard operation
phylanx copied to clipboard

Postincrement/preincrement range iterator problem

Open hkaiser opened this issue 7 years ago • 0 comments

@hkaiser If I write the code this way it doesn't work properly:

auto decoded_dense = phylanx::execution_tree::extract_numeric_value(*it++);
auto log_prob = phylanx::execution_tree::extract_numeric_value(*it);

HPX_TEST_EQ(
        phylanx::ir::node_data<double>(std::move(expected_decoded_dense)), decoded_dense);
HPX_TEST(
        allclose(phylanx::ir::node_data<double>(std::move(expected_log_prob)), log_prob));

but if I do this instead:

auto decoded_dense = phylanx::execution_tree::extract_numeric_value(*it);
auto log_prob = phylanx::execution_tree::extract_numeric_value(*++it);

HPX_TEST_EQ(
        phylanx::ir::node_data<double>(std::move(expected_decoded_dense)), decoded_dense);
HPX_TEST(
        allclose(phylanx::ir::node_data<double>(std::move(expected_log_prob)), log_prob));

it works properly.

Originally posted by @scheherzade in https://github.com/STEllAR-GROUP/phylanx/pull/938

hkaiser avatar Apr 14 '19 15:04 hkaiser