Repository: xbmc/xbmc
File: xbmc/platform/win32/WinRtUtil.cpp (C++)

Code before:
extern HWND g_hWnd;
#endif

static constexpr std::string_view AdvancedColorKindToString(AdvancedColorKind kind)
{
  switch (kind)
  {
    case AdvancedColorKind::StandardDynamicRange:
      return "SDR";
    case AdvancedColorKind::WideColorGamut:
      return "WCG";
    case AdvancedColorKind::HighDynamicRange:
      return "HDR";
    default:
      return "unknown";
  }
}

static void LogAdvancedColorInfo(AdvancedColorInfo colorInfo)
{
  std::string availableAdvColorKind;
  std::array<AdvancedColorKind, 3> kinds{AdvancedColorKind::StandardDynamicRange,
                                         AdvancedColorKind::WideColorGamut,
                                         AdvancedColorKind::HighDynamicRange};

  for (auto kind : kinds)
  {
    if (colorInfo.IsAdvancedColorKindAvailable(kind))
      availableAdvColorKind.append(AdvancedColorKindToString(kind)).append(" ");
  }

  CLog::LogF(LOGDEBUG, "Current advanced color kind: {}, supported kinds: {}",
             AdvancedColorKindToString(colorInfo.CurrentAdvancedColorKind()),
             availableAdvColorKind);
}

HDR_STATUS CWinRtUtil::GetWindowsHDRStatus()
{
  DisplayInformation displayInformation{nullptr};

#ifdef TARGET_WINDOWS_STORE
  displayInformation = DisplayInformation::GetForCurrentView();

  if (!displayInformation)
  {
    CLog::LogF(LOGERROR, "unable to retrieve DisplayInformation.");
    return HDR_STATUS::HDR_UNKNOWN;
  }
#else
  auto factory{
      winrt::try_get_activation_factory<DisplayInformation, IDisplayInformationStaticsInterop>()};

Review comment (suggestion):
```suggestion
  for (const auto& kind : kinds)
```

Code after:
extern HWND g_hWnd;
#endif

static constexpr std::string_view AdvancedColorKindToString(AdvancedColorKind kind)
{
  switch (kind)
  {
    case AdvancedColorKind::StandardDynamicRange:
      return "SDR";
    case AdvancedColorKind::WideColorGamut:
      return "WCG";
    case AdvancedColorKind::HighDynamicRange:
      return "HDR";
    default:
      return "unknown";
  }
}

static void LogAdvancedColorInfo(AdvancedColorInfo colorInfo)
{
  std::string availableKinds;
  static constexpr std::array<AdvancedColorKind, 3> kinds{AdvancedColorKind::StandardDynamicRange,
                                                          AdvancedColorKind::WideColorGamut,
                                                          AdvancedColorKind::HighDynamicRange};

  for (const AdvancedColorKind& kind : kinds)
  {
    if (colorInfo.IsAdvancedColorKindAvailable(kind))
      availableKinds.append(AdvancedColorKindToString(kind)).append(" ");
  }

  CLog::LogF(LOGDEBUG, "Current advanced color kind: {}, supported kinds: {}",
             AdvancedColorKindToString(colorInfo.CurrentAdvancedColorKind()), availableKinds);
}

HDR_STATUS CWinRtUtil::GetWindowsHDRStatus()
{
  DisplayInformation displayInformation{nullptr};

#ifdef TARGET_WINDOWS_STORE
  displayInformation = DisplayInformation::GetForCurrentView();

  if (!displayInformation)
  {
    CLog::LogF(LOGERROR, "unable to retrieve DisplayInformation.");
    return HDR_STATUS::HDR_UNKNOWN;
  }
#else
  auto factory{
      winrt::try_get_activation_factory<DisplayInformation, IDisplayInformationStaticsInterop>()};