Can and should C++ class constructors be declared __attribute__((pure)) if they only can reach data via its parameters? And in which cases should they be qualified as __attribute__((const))?
C++ class constructors qualified as __attribute__((pure)) or __attribute__((const))
340 views Asked by Nordlöw At
1
GCC warns when you qualify constructors as
pureorconst. This is because a constructor does not return anything (returnsvoid) and it does not make much sense to have apureorconstattributes on such functions.See godbolt demo here.
From GCC documentation: