ValeevGroup / SeQuant

SeQuant: Symbolic Algebra of Tensors over Operators and Scalars
GNU General Public License v3.0
17 stars 6 forks source link

consider `Singleton<T>::instance()` returning `T&` #226

Closed evaleev closed 4 months ago

evaleev commented 4 months ago

I think making instance() return a pointer makes the API worse as now there is (at least semantically) the possibility of that pointer being nullptr. I much prefer to use references for stuff that can't be null as here there is an actual enforcement of this claim and every user can easily see it (whereas for pointers the best you can do is a promise in the documentation of some function).

Originally posted by @Krzmbrzl in https://github.com/ValeevGroup/SeQuant/issues/222#issuecomment-2218120202