ドラフトとチェッカーの位置を設定するために、密接に関連する2つの文法を解析できる、動作中のSpirit-X3パーサーがあります。文法の 2 つの方言のパーサーとして、2つの変数テンプレートの特殊化を定義します。
// general variable template
template<class Format>
auto const position = []{};
// template specialization for algebraic notation (squares of the form "a1"-"h8")
template<>
auto const position<ast::ALG> = attribute_cast<ast::position<ast::ALG>>
(
/* code depending on ast::ALG, omitted for brevity */
);
// template specialization for numeric notation (squares numbered 1 through N)
template<>
auto const position<ast::NUM> = attribute_cast<ast::position<ast::NUM>>
(
/* code depending on ast::NUM, omitted for brevity */
);
このコードは、 Clangとg++の両方で、テスト入力をコンパイルして正しく解析し ます。
2 つの変数テンプレートの特殊化はまったく同じ形式でテンプレート パラメーターに依存するため、それらを一般的な変数テンプレートに統合したいと考えています。
template<class Format>
auto const position = attribute_cast<ast::position<Format>>
(
/* code depending on Format, omitted for brevity */
);
これは、 g++に対しても正しくコンパイルおよび解析します。Clang 用にもコンパイルされますが、Coliruではなく、Wandboxでの入力のみを正しく解析します。apt.llvm.orgの clang-3.8.0 を使用した私自身の開発ボックスでは、 Coliruと同じ誤った動作が発生します。
質問: 変数テンプレートの特殊化に関する Clang のバグはありますか? そのバグを回避するために、Wandbox と同じ方法で Clang を構成するにはどうすればよいですか? それともSpirit-X3関連のバグですか?