簡體   English   中英

錯誤:尚未聲明“ std :: enable_if_t”

[英]error: ‘std::enable_if_t’ has not been declared

目前,我對這行代碼有疑問。 其顯示此錯誤消息error: 'std::enable_if_t' has not been declared 我已經包含了#include <type_traits>頭文件,但是它仍然相同。 下面是我的src代碼:

template<class T>
std::string toJSON(const T& o,std::enable_if_t<detail::hasBindFunction<T>::value>* =nullptr)

我已經將c ++版本添加到我的binding.gyp文件中。 "cflags": [ "-std=c++14" ], 錯誤仍然顯示在那里。

我可以知道如何解決此錯誤。

std::enable_if_t是C ++ 14功能,因此您需要在編譯器中啟用C ++ 14。 在Clang或GCC中,這是通過-std=c++14標志完成的。

我在這里找到這個

{
    "targets": [
    {
        "target_name": "yourproject",
        "sources": [ "yourproject.cpp" ],
        "cflags" : [ "-std=c++14", "-stdlib=libc++" ]
        "conditions": [
          [ 'OS!="win"', {
            "cflags+": [ "-std=c++14" ],
            "cflags_c+": [ "-std=c++14" ],
            "cflags_cc+": [ "-std=c++14" ],
          }],
          [ 'OS=="mac"', {
            "xcode_settings": {
              "OTHER_CPLUSPLUSFLAGS" : [ "-std=c++14", "-stdlib=libc++" ],
              "OTHER_LDFLAGS": [ "-stdlib=libc++" ],
              "MACOSX_DEPLOYMENT_TARGET": "10.7"
            },
          }],
        ],
    }
    ]
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM