Clang++ warns that instantiations of this inline template function
ex_to<T>(const ex &) are "expression with side effects [that] will be
evaluated despite being used as an operand to 'typeid'".
Let's declare this ex_to<T>() as a pure function (i.e. having no
side effects) for compilers which support __attribute__((__pure__)).
GCC seems to support this attribute since more than ten years.
#define unlikely(cond) __builtin_expect((cond), 0)
#define likely(cond) __builtin_expect((cond), 1)
#define attribute_deprecated __attribute__ ((deprecated))
+#define attribute_pure __attribute__((__pure__))
#else
#define unlikely(cond) (cond)
#define likely(cond) (cond)
#define attribute_deprecated
+#define attribute_pure
#endif
#endif // ndef GINAC_COMPILER_DEP_H
#include "basic.h"
#include "ptr.h"
+#include "compiler.h"
#include <functional>
#include <iosfwd>
* @param e expression
* @return reference to object of class T
* @see is_exactly_a<class T>() */
-template <class T>
+template <class T> attribute_pure
inline const T &ex_to(const ex &e)
{
GINAC_ASSERT(is_a<T>(e));