Slicing std::valarray using references?

Joined
Oct 23, 2008
Messages
3
Reaction score
0
Dear all,

I am facing quite an annoying problem I can't solve. I have a std::valarray<T>, where T can be anything and I need slices of it to work locally on them.

If the elements T contained in the valarray are big (not to say HUGE), the usage of std::slice is quite inconvenient, since temporary copies of the objects in the slice are created.

Same problem in case my T is small (let's say T = int), but my slice contains 1e6 elements.

An approach using references would be much more efficient than std::slice in my opinion, but I don't know how to implement an object like this. The only alternative to that I have in mind is to use std::valarray<T*>, but I don't really like the pointer syntax and I'd prefer to avoid it.

Any suggestions, please?

Best regards,

MrMF
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top