一部のコードを読みやすくし、タイプミスを避けるためpublic
に、ヘッダー ファイルのクラス定義のセクションで次のステートメントを使用しています。
using Assembly_Tuple = std::tuple <std::vector <std::string>, Trigger_Map, Attribute_Map>;
Assembly_Tuple
戻り値の型としてヘッダー ファイルで関数を宣言しています。
Assembly_Tuple merge_node_attributes(const std::string& node_name, std::string tmpl_name="");
そして、ソースファイルで関数を定義しています:
Widget_Server_Interface::Assembly_Tuple
Widget_Server_Interface::merge_node_attributes(const std::string& n, const std::string& t)
{
//...
}
しかし、コンパイルしようとすると、次のエラーが発生します。
src/WidgetServer/WidgetServerInterface.cpp:31:1: error: ‘Assembly_Tuple’ in ‘class Widget_Server_Interface’ does not name a type
ただし、定義内では問題ありません。
その行をひどいものに変更すると:
std::tuple<std::vector<std::string>, Trigger_Map, std::map<int,Node_Value>>
Widget_Server_Interface::merge_node_attributes (...) {...}
大丈夫だよ。エイリアスが公開されていて、クラスの名前空間を明示的に呼び出しているにもかかわらず、明らかに問題はスコープ外でエイリアスを使用していることです。
私は Bjarne の本を見ましたが、彼はこれが合法かどうかについてどこにも言及していません。
これはgcc 4.7を使用しています。
ほとんどの場合、これが有効でない理由を知りたいだけです。