You are viewing a single thread.
View all comments
3 points

I agree we should use operator overloading only when it really fits the use case. Especially the function call operator is easily misused.

I don’t completely agree with Raymond Chen here though. Firstly I don’t think providing both an explicit Load() function and the function call operator is the solution. Just keep things simple and obvious: provide Load() and remove the function call operator.

Secondly, why is StorageLoader even a class (or actually a struct here, but we know that’s the same thing in C++)? Unless Raymond is leaving out something essential, there is no state. Just make a function:

template<typename DataType> LoadFromStorage(StorageOptions<DataType> const* options) { // … }

permalink
report
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