C++ trick I pulled today. Like an explicit constructor but context dependent. Any alternatives from folks who’ve needed to do similar? One thing I still need to dig into a little deeper is how copy elision behaves here.

You are viewing a single thread.
View all comments View context
2 points

For the array type it can be useful to allow implicit copy to different arithmetic types (design choice, I’m now back to explicit constructors to disallow this for what it’s worth). If allowed though, I still wanted a compile time check like this to ensure that it wasn’t happening by accident in particular circumstances.

permalink
report
parent
reply

C++

!cpp@programming.dev

Create post

The center for all discussion and news regarding C++.

Rules

  • Respect instance rules.
  • Don’t be a jerk.
  • Please keep all posts related to C++.

Community stats

  • 149

    Monthly active users

  • 263

    Posts

  • 535

    Comments