boost::has_left_shift does not work with containers

オープン
#196 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
cpp
領域
tooling

調査の方向性

まず、GCC 14.2.1 または Clang 18.1.6 で issue の最小再現をコンパイルし、次に has_left_shift の実装と既存のテストを調べます。std::pair と std::vector に対して示されているストリーム挿入演算子を trait が認識し、関連するテストが引き続き成功すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

The following example is a minimal reproduction of this issue:

#define BOOST_TEST_MODULE ExampleTestModule
#include <boost/static_assert.hpp>
#include <boost/test/included/unit_test.hpp>

inline std::ostream& operator<<(std::ostream& os, const std::pair<int, int>& _) {
    os << "Pairwise operator called!" << std::endl;
    return os;
}

BOOST_STATIC_ASSERT(boost::has_left_shift<std::ostream&, const std::pair<int, int>&>::value);

// If you comment out the above static assertion, the code compiles and this
// test case prints, as expected "Pairwise operator called!"
BOOST_AUTO_TEST_CASE(test_case1)
{
    std::pair<int, int> pair;
    std::cout << pair;
}

Compiling with gcc 14.2.1 results in:

ex.cpp:10:87: error: static assertion failed: boost::has_left_shift<std::ostream&, const std::pair<int, int>&>::value
   10 | BOOST_STATIC_ASSERT(boost::has_left_shift<std::ostream&, const std::pair<int, int>&>::value);

I have similar results in clang 18.1.6:

ex.cpp:10:21: error: static assertion failed due to requirement 'boost::has_left_shift<std::basic_ostream<char, std::char_traits<char>> &, const std::pair<int, int> &, boost::binary_op_detail::dont_care>::value': boost::has_left_shift<std::ostream&, const std::pair<int, int>&>::value
   10 | BOOST_STATIC_ASSERT(boost::has_left_shift<std::ostream&, const std::pair<int, int>&>::value);
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/boost/static_assert.hpp:71:55: note: expanded from macro 'BOOST_STATIC_ASSERT'
   71 | #     define BOOST_STATIC_ASSERT( ... ) static_assert(__VA_ARGS__, #__VA_ARGS__)
      |   

The same happens if you use a std::vector<int> instead.

主要言語
C++
スター
65
フォーク
88
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

boostorg/type_traits のほかの issue

boostorg/type_traits の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。