Comments (7)
b[std::slice(0,2,3)] = {'x','y'};
↓
b[std::slice(0,2,3)] = a_type({'x','y'});
コンパイル時に明示的にa_type型にしてあげればClang-HEADでも期待通りの結果が得られますね。
この問題の直接の原因は {'x','y'} を std::valarray の std::slice の operator= がClang-HEADではstd::valarrayに型変換されてくれない挙動のようです。
cpprefjpとしての問題は、このClangの挙動({'x','y'}をstd::valarray型に暗黙的に変換しない)がC++規格として正しいか、という事になるかと思います。
さしあたりは、Clang-HEADでコンパイルできない事の解決としても、明示的なコードとしても、冒頭に挙げたClang-HEADでもコンパイル可能なパターンへの変更をpull-reqしておきます。
from site.
libc++ の問題のように見えますね。
slice_array
には
void operator=(const valarray<T>&) const;
が無きゃならないのに、libc++ には
template <class _Expr>
typename enable_if<__is_val_expr<_Expr>::value, void>::type operator=(const _Expr& __v) const;
しかないです。
operator=
の引数がテンプレートパラメータなので、initializer_list
から valarray
への暗黙変換がされないのではないかと思います。
試しに {'x','y'}
を std::valarray<v_type>{'x','y'}
に変更したら clang & libc++ でもコンパイルできました。
http://melpon.org/wandbox/permlink/KSMdklUGHtL9oQWJ
from site.
あ、かぶった…
そして a_type ありましたね…orz
上に書いたとおり、clang でも libstdc++ 使えばコンパイルできます。
from site.
本来は元のままでもコンパイルされて然るべき、とは言え最新のClang++というかlibc++で通らないサンプルを注釈を付けて掲載するのもユーザーフレンドリーではありませんし、hotfixの対応はそれほど複雑化するものではないので、どなたか確認頂いた上でさしあたりはpull-reqの修正をmergeして頂ければいいかな、と思います。
と、同時にlibc++にバグ報告を挙げるべきででしょうか。
※只今よりお仕事タイム的にしばらくスレッドに出没できなくなります。夕方以降にまたスレッド確認します。
from site.
バグ報告が終わったら Close する方向で。
from site.
バグレポの栄誉頂きました!
http://llvm.org/bugs/show_bug.cgi?id=17814
#英文は気にしない方向で…
from site.
ありがとうございます!
valarray のコードは修正されたし、バグ報告もしたので、これで問題は解決したということで Close します。
from site.
Related Issues (20)
- [C++26] variantのvisitメンバ関数
- [C++26] 共用体のどのメンバがアクティブかを判定する関数
- [C++26] ファイルストリームのnative handle
- [C++26] bitsetのstring_viewインタフェース
- [C++26] `<cmath>`と`<complex>`のさらなるconstexpr対応
- [C++26] copyable_function
- [C++26] bind_frontとbind_backを非型テンプレート引数での呼び出しに対応
- [C++26] submdspan
- cpprefjpサイトのサイドバーが壊れています HOT 2
- [C++26] 2023-10 Mailingに対応する
- [スポンサー] 時雨堂さま - ゴールドスポンサー HOT 2
- [スポンサー] nodchipさま - ブロンズスポンサー HOT 1
- outer link check failed at e30c3ae988aed71a6df562fd71062079949a1d4e HOT 1
- outer link check failed at beb148edbf96be6eb9a31ee14b58a886db3e4e99 HOT 6
- outer link check failed at 4d5c0edfcd79661472afc00a695d017297e4d1d9
- 2023年分の貢献ポイントと報酬のレビューをお願いします HOT 1
- 2023年 報酬受け取りの申請をお願いします HOT 13
- [C++26] 2023-12 Mailingに対応する HOT 1
- [スポンサー] 株式会社ペガシス様・シルバースポンサー HOT 1
- [スポンサー] 株式会社COCOTONE様・ゴールドスポンサー HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from site.