ddc icon indicating copy to clipboard operation
ddc copied to clipboard

Matrix::operator<< not working properly

Open blegouix opened this issue 1 year ago • 5 comments

See https://github.com/CExA-project/ddc/pull/433#discussion_r1590651750

blegouix avatar May 06 '24 08:05 blegouix

I think a const might be missing:

std::ostream& operator<<(std::ostream& os) const

@EmilyBourne When you tried this function, do you remember if you were passing a const Matrix to the insertion operator << ?

tpadioleau avatar May 14 '24 13:05 tpadioleau

Hmm good question. I don't remember but I was probably printing a Matrix via the SplineBuilder getter. If that was indeed the case, then it would be const

EmilyBourne avatar May 14 '24 13:05 EmilyBourne

I have just checked and this seems to be unrelated to the constness:

/home/emily/Code/ddc/include/ddc/kernels/splines/spline_builder.hpp:497:15: error: no match for ‘operator<<’ (operand types are ‘std::ostream’ {aka ‘std::basic_ostream<char>’} and ‘ddc::detail::Matrix’)
  497 |     std::cout << (*matrix) << std::endl;
      |     ~~~~~~~~~ ^~ ~~~~~~~~~
      |          |        |
      |          |        ddc::detail::Matrix
      |          std::ostream {aka std::basic_ostream<char>}

EmilyBourne avatar May 14 '24 18:05 EmilyBourne

The somewhat absurd code:

(*matrix) << std::cout;

compiles correctly and prints the matrix (if I provide an arbitrary implementation of get_element)

EmilyBourne avatar May 14 '24 18:05 EmilyBourne

Let's go back to the free function version then

tpadioleau avatar May 15 '24 10:05 tpadioleau