3
0

Utils.h 674 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/std/any.h>
  10. namespace ExpressionEvaluation
  11. {
  12. class Utils
  13. {
  14. public:
  15. template<typename ValueType>
  16. static ValueType GetAnyValue(const AZStd::any& operand, ValueType defaultValue = ValueType{})
  17. {
  18. if (operand.is<ValueType>())
  19. {
  20. return AZStd::any_cast<ValueType>(operand);
  21. }
  22. return defaultValue;
  23. }
  24. };
  25. }