C++函数体中const bool isResultEmpty {pSource->getCache().isEmpty(type)};这句话是啥意思?


const bool isResultEmpty {pSource->getCache().isEmpty(type)};

这是C++函数体中的一句话,从语法和表面上猜测,大概是啥意思?

算我见识小,第一次见到这样写的const bool isResultEmpty {pSource->getCache().isEmpty(type)}。不知道是什么时候新加的C++写法?!
如果定义数组应该是const bool isResultEmpty[] = {pSource->getCache().isEmpty(type)},这样是定义一个长度为1的bool型数组,值是psource的cache是否是空的

整个函数体如下:



void AudioPlayer::onCategoryAvailabiltyChanged(const std::string& sourceId, BrowseType type)
{
    DLT_LOG_FCN_CXX(AudioDltContext, DLT_LOG_INFO, "");

    auto pSource = m_audioSourceManager->findSource(sourceId); /* 查找媒体源 */
    if (!pSource) /* 没找到 */
    {
        DLT_LOG_FCN_CXX(AudioDltContext, DLT_LOG_WARN, "Source " + sourceId + " not found!");
        return;
    }
    const bool isResultEmpty {pSource->getCache().isEmpty(type)};
    DLT_LOG_FCN_CXX(AudioDltContext, DLT_LOG_INFO, browseTypeToString(type), "Result is empty:", isResultEmpty);

    if (pSource->isSelected() == true /* 媒体源选择OK */
            && type == BrowseType::FAVORITES)/* 浏览类型:收藏夹 */
    {
        m_indications.SetIndication(IAudioPlayer::IND_IsFavoritesCategoryAvailable, !isResultEmpty);
        m_pAudioPlayerEvent->notifyIndicationsChanged(m_indications);
    }
    else if (pSource->isIPod()) /* 媒体源是IPod */
    {
        switch (type)
        {
            case BrowseType::AUDIOBOOKS:/* 有声读物 */
            {
                m_indications.SetIndication(IAudioPlayer::IND_IsAudiobookCategoryAvailable, !isResultEmpty);
                break;
            }
            case BrowseType::PLAYLISTS: /* 播放列表 */
            {
                m_indications.SetIndication(IAudioPlayer::IND_IsPlaylistCategoryAvailable, !isResultEmpty);
                break;
            }
            case BrowseType::ALLTRACKS: /* 所有曲目 */
            {
                m_indications.SetIndication(IAudioPlayer::IND_IsIpodAudioAvailable, !isResultEmpty);
                break;
            }
            case BrowseType::PODCASTS: /* 播客 */
            {
                m_indications.SetIndication(IAudioPlayer::IND_IsPodcastCategoryAvailable, !isResultEmpty);
                break;
            }
            default:
            {
                break;
            }
        }
        m_pAudioPlayerEvent->notifyIndicationsChanged(m_indications);
    }
    else if (pSource->getSourceType() == IAudioPlayer::AUDIOPLAYERSOURCES_USB /* 媒体源是USB、USB1 */
             || pSource->getSourceType() == IAudioPlayer::AUDIOPLAYERSOURCES_USB_1)
    {
        if (type == BrowseType::PLAYLISTS) /* 播放列表 */
        {
            m_indications.SetIndication(IAudioPlayer::IND_IsPlaylistCategoryAvailable, !isResultEmpty);
            m_pAudioPlayerEvent->notifyIndicationsChanged(m_indications);
        }
        else if (type == BrowseType::ALLTRACKS) /* 所有曲目 */
        {
            m_indications.SetIndication(IAudioPlayer::IND_IsAudioAvailable, !isResultEmpty);
            m_pAudioPlayerEvent->notifyIndicationsChanged(m_indications);
        }
    }
}