2017-10-30 11 views
0

下記のプログラムをコンパイルしようとすると、次のエラーが発生します。コンパイルに成功するには、プログラムで何を変更する必要がありますか? GCC 4.9.2のように見えるいくつかのnoexcept移動コンストラクタは "= default"として実装できません。gcc 4.9.2コンパイルエラー:AssetLinkData

トラブルを引き起こす行がある: AssetLinkData::AssetLinkData(AssetLinkData&& other) noexcept = default;


COMPILATION ERROR: FAILED: obj/browser/asset_link_data.o g++ -MMD -MF (I removed many more flags)

asset_link_data.cc: error: function 'password_manager::AssetLinkData::AssetLinkData(password_manager::AssetLinkData&&)' defaulted on its redeclaration with an exception-specification that differs from the implicit declaration 'password_manager::AssetLinkData::AssetLinkData(password_manager::AssetLinkData&&)' AssetLinkData::AssetLinkData(AssetLinkData&& other) noexcept = default;


ソース・コード:Imはasset_link_data.hの内容を追加することを下回る

#include "asset_link_data.h" 

#include <algorithm> 

#include <utility> 

#include "base/json/json_reader.h" 

#include "base/json/json_value_converter.h" 

#include "base/values.h" 

namespace password_manager { namespace { 

constexpr char kGetLoginsRelation[] = 
    "delegate_permission/common.get_login_creds"; constexpr char kWebNamespace[] = "web"; 

} // namespace 

AssetLinkData::AssetLinkData() = default; 

AssetLinkData::AssetLinkData(AssetLinkData&& other) noexcept = default; 

AssetLinkData::~AssetLinkData() = default; AssetLinkData& AssetLinkData::operator=(AssetLinkData&& other) = default; 
} // namespace password_manager 

#ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SITE_AFFILIATION_ASSET_LINK_DATA_H_ 
#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SITE_AFFILIATION_ASSET_LINK_DATA_H_ 

#include <string> 
#include <vector> 

#include "base/macros.h" 
#include "url/gurl.h" 

namespace password_manager { 

// The class parses an asset link file. The spec for the format is 
// https://github.com/google/digitalassetlinks/blob/master/well-known/details.md 
// The class cares only about two types of statements: 
// - includes. Those are just a reference to a file to be loaded and parsed. 
// - "get_login_creds" permission to a web page. That means that the target is 
// allowed to get the credentials saved for the source. 
// Only HTTPS URLs are taken into account. 
class AssetLinkData { 
public: 
    AssetLinkData(); 
    AssetLinkData(AssetLinkData&& other) noexcept; 
    ~AssetLinkData(); 

    AssetLinkData& operator=(AssetLinkData&& other); 

    bool Parse(const std::string& data); 

    const std::vector<GURL>& includes() const { return includes_; } 
    const std::vector<GURL>& targets() const { return targets_; } 

private: 
    std::vector<GURL> includes_; 
    std::vector<GURL> targets_; 

    DISALLOW_COPY_AND_ASSIGN(AssetLinkData); 
}; 

} // namespace password_manager 
#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SITE_AFFILIATION_ASSET_LINK_DATA_H_ 
+0

? – Kevin

+0

Kevin: コードからincludeステートメントを削除しました。最初のインクルードは次のように書いています: #include "asset_link_data.h" – bari

+0

質問を編集して、 'AssetLinkData'の定義を含めることはできますか?そして、エラーに関係のないもの( 'Target'、' Statement'、 'AssetLinkData :: Parse'など)を取り除きます。 – Kevin

答えて

1

エラーメッセージがかなり明確である:

defaulted on its redeclaration with an exception-specification that differs from the implicit declaration

あなたが先に行くと、コンストラクタにそれをとにかくするつもりだった方法を定義するために、コンパイラを求めているが、あなたははを求めています

noexceptなるようにコンストラクタ...と、デフォルトコンストラクタは、この問題を解決するには noexcept

ないが作成した、あなたのいずれかがnoexcept指定子を削除する必要があります

AssetLinkData::AssetLinkData(AssetLinkData&& other) = default; 

か、あなたは無除き、指定をしたい場合、あなたは手で昔ながらの方法をそれをクランクする必要があります: `AssetLinkData`が定義されて

AssetLinkData::AssetLinkData(AssetLinkData&& other) noexcept 
: includes_(std::move(other.includes_)) 
, targets_ (std::move(other.targets_)) 
{} 
+0

このエラーを修正するにはどうすればよいですか?コードで何を修正する必要がありますか?より関連性の高い情報で質問を編集しました... – bari

+0

'noexcept'指定子を削除した場合、プログラムの動作方法を変更していますか?私は毎日それを使用するためにクロームブラウザのソースコードをコンパイルしようとしていますが、これは私にトラブルを引き起こしている唯一のファイル(何千ものもの)です... – bari

+0

あなたは動作する方法を変更していますそれは*振る舞うかもしれない)。 'noexcept'は純粋に化粧品ではありません。 –

関連する問題