Skip to content

Commit

Permalink
Merge pull request #694 from andreasfertig/papersUpdate
Browse files Browse the repository at this point in the history
Added multiple test for already working papers from C++17 - 26.
  • Loading branch information
andreasfertig authored Jan 13, 2025
2 parents 1eb4c2c + fb8cc82 commit f243226
Show file tree
Hide file tree
Showing 14 changed files with 218 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/p0195Test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
template<class... Ts>
struct overload : Ts... {
using Ts::operator()...;
};

// #B CTAD
template<class... Ts>
overload(Ts...) -> overload<Ts...>;

int main() {
overload ol{
[](int&) { },
[](char&) { },
};
}

90 changes: 90 additions & 0 deletions tests/p0195Test.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
template<class ... Ts>
struct overload : public Ts...
{
using Ts::operator()...;
};

/* First instantiated from: p0195Test.cpp:11 */
#ifdef INSIGHTS_USE_TEMPLATE
template<>
struct overload<__lambda_12_7, __lambda_13_7> : public __lambda_12_7, public __lambda_13_7
{
using __lambda_12_7::operator();
// inline /*constexpr */ void ::operator()(int &) const;

using __lambda_13_7::operator();
// inline /*constexpr */ void ::operator()(char &) const;

// inline constexpr overload<__lambda_12_7, __lambda_13_7> & operator=(const overload<__lambda_12_7, __lambda_13_7> &) /* noexcept */ = delete;
// inline constexpr overload<__lambda_12_7, __lambda_13_7> & operator=(overload<__lambda_12_7, __lambda_13_7> &&) /* noexcept */ = delete;
};

#endif

template<class ... Ts>
overload(Ts...) -> overload<Ts...>;

/* First instantiated from: p0195Test.cpp:11 */
#ifdef INSIGHTS_USE_TEMPLATE
template<>
overload(__lambda_12_7 __0, __lambda_13_7 __1) -> overload<__lambda_12_7, __lambda_13_7>;
#endif


int main()
{

class __lambda_12_7
{
public:
inline /*constexpr */ void operator()(int &) const
{
}

using retType_12_7 = void (*)(int &);
inline constexpr operator retType_12_7 () const noexcept
{
return __invoke;
};

private:
static inline /*constexpr */ void __invoke(int & __param0)
{
__lambda_12_7{}.operator()(__param0);
}

public:
// inline /*constexpr */ __lambda_12_7 & operator=(const __lambda_12_7 &) /* noexcept */ = delete;
// inline /*constexpr */ __lambda_12_7(__lambda_12_7 &&) noexcept = default;

};


class __lambda_13_7
{
public:
inline /*constexpr */ void operator()(char &) const
{
}

using retType_13_7 = void (*)(char &);
inline constexpr operator retType_13_7 () const noexcept
{
return __invoke;
};

private:
static inline /*constexpr */ void __invoke(char & __param0)
{
__lambda_13_7{}.operator()(__param0);
}

public:
// inline /*constexpr */ __lambda_13_7 & operator=(const __lambda_13_7 &) /* noexcept */ = delete;
// inline /*constexpr */ __lambda_13_7(__lambda_13_7 &&) noexcept = default;

};

overload<__lambda_12_7, __lambda_13_7> ol = {__lambda_12_7(__lambda_12_7{}), __lambda_13_7(__lambda_13_7{})};
return 0;
}
4 changes: 4 additions & 0 deletions tests/p0245Test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
int main()
{
auto hexFloat = 0x3.ABCp-10;
}
5 changes: 5 additions & 0 deletions tests/p0245Test.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
int main()
{
double hexFloat = 0.0035848617553710938;
return 0;
}
10 changes: 10 additions & 0 deletions tests/p0330Test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// cmdline:-std=c++23

#include <vector>

int main() {
std::vector<int> v{0, 1, 2, 3};
for (auto i = 0uz, s = v.size(); i < s; ++i) {
/* use both i and v[i] */
}
}
10 changes: 10 additions & 0 deletions tests/p0330Test.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <vector>

int main()
{
std::vector<int, std::allocator<int> > v = std::vector<int, std::allocator<int> >{std::initializer_list<int>{0, 1, 2, 3}};
for(unsigned long i = 0UL, s = v.size(); i < s; ++i) {
}

return 0;
}
5 changes: 5 additions & 0 deletions tests/p0683Test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// cmdline:-std=c++20

struct S {
int x : 8 = 42;
};
5 changes: 5 additions & 0 deletions tests/p0683Test.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
struct S
{
int x:8 = 42;
};

6 changes: 6 additions & 0 deletions tests/p1102Test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// cmdline:-std=c++23

int x{3};
auto noSean = [s2 = x] mutable { // Currently a syntax error.
++s2;
};
21 changes: 21 additions & 0 deletions tests/p1102Test.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
int x = {3};

class __lambda_4_15
{
public:
inline /*constexpr */ void operator()()
{
++s2;
}

private:
int s2;

public:
__lambda_4_15(int & _s2)
: s2{_s2}
{}

};

__lambda_4_15 noSean = __lambda_4_15{x};
2 changes: 2 additions & 0 deletions tests/p1401Test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
constexpr int N{1};
static_assert(N);
2 changes: 2 additions & 0 deletions tests/p1401Test.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
constexpr const int N = {1};
/* PASSED: static_assert(static_cast<bool>(N)); */
13 changes: 13 additions & 0 deletions tests/p2128Test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// cmdline:-std=c++2b

class mdspan {
int field{};
public:
template<class... IndexType>
constexpr auto& operator[](IndexType...) { return field; }
};

int main() {
mdspan s{};
s[1, 1, 1] = 42;
}
29 changes: 29 additions & 0 deletions tests/p2128Test.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class mdspan
{
int field;

public:
template<class ... IndexType>
inline constexpr auto & operator[](IndexType...)
{
return this->field;
}

#ifdef INSIGHTS_USE_TEMPLATE
template<>
inline constexpr int & operator[]<int, int, int>(int __0, int __1, int __2)
{
return this->field;
}
#endif

// inline constexpr mdspan() noexcept = default;
};


int main()
{
mdspan s = mdspan{};
s.operator[](1, 1, 1) = 42;
return 0;
}

0 comments on commit f243226

Please sign in to comment.