AsPJT / AsPJT/DungeonTemplateLibrary

非リテラル型な任意のUDT(User-Defined Type)に対して、constexprコピーコンストラクタはill-formedになる

Open
#22 10 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
1.5k
Forks
89
PR merge metrics
No merged PRs in 30d

Description

以前某中3女子に質問をしたことがあって、

>https://gcc.gnu.org/ml/libstdc++/2012-10/msg00120.html

``` patch
diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono
index 209f395..d920a7d 100644
--- a/libstdc++-v3/include/std/chrono
+++ b/libstdc++-v3/include/std/chrono
@@ -250,7 +250,10 @@ _GLIBCXX_END_NAMESPACE_VERSION
// 20.11.5.1 construction / copy / destroy
constexpr duration() = default;

- constexpr duration(const duration&) = default;
+ // NB: Make constexpr implicit. This cannot be explicitly
+ // constexpr, as any UDT that is not a literal type with a
+ // constexpr copy constructor will be ill-formed.
+ duration(const duration&) = default;

template::value
```

という変更がどういう意味かを問い合わせたことがありました。


と回答していただきました。

さて、例えば

```cpp
template
struct Coordinate1Dimensional {
Int_ x{};
constexpr Coordinate1Dimensional() = default;
constexpr Coordinate1Dimensional(const Int_& x_) noexcept :x(x_) {};
};
```

をみると、上と全く同じ状況であることがわかります。

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue discusses Coordinate1Dimensional and compares its constructors with the std::chrono duration change. Start by locating Coordinate1Dimensional and checking its constructor declarations and existing tests; no specific repository file or test is named. Done means establishing whether the constexpr declaration is well-formed for arbitrary Int_ types and documenting or correcting the affected code.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.