Skip to content

Commit

Permalink
Merge pull request #106 from bemanproject/remove_target_version_from_…
Browse files Browse the repository at this point in the history
…library_names

Remove target version from library names
  • Loading branch information
neatudarius authored Feb 6, 2025
2 parents 934997b + 6497f04 commit 711171c
Show file tree
Hide file tree
Showing 15 changed files with 142 additions and 140 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ if(OPTIONAL_ENABLE_TESTING)
add_executable(beman_optional_test)
target_sources(
beman_optional_test
PRIVATE FILE_SET beman_optional_test_headers TYPE HEADERS BASE_DIRS src
PRIVATE
FILE_SET beman_optional_test_headers
TYPE HEADERS
BASE_DIRS tests
)

add_subdirectory(src/beman/optional/tests)
add_subdirectory(tests/beman/optional)
endif()

add_subdirectory(include/beman/optional)
Expand Down
6 changes: 3 additions & 3 deletions papers/P2988/mybiblio.bib
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ @misc{rawgithu58:online
note = {(Accessed on 08/14/2024)}
}

@misc{The_Beman_Project_beman_optional26,
@misc{The_Beman_Project_beman_optional,
author = {The Beman Project},
license = {Apache-2.0},
title = {{beman.optional26}},
howpublished = {\url{https://github.com/bemanproject/optional26}},
title = {{beman.optional}},
howpublished = {\url{https://github.com/bemanproject/optional}},
month = {},
year = {},
}
2 changes: 1 addition & 1 deletion papers/P2988/optional_ref_wording.tex
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ \chapter{Impact on the standard}
The proposed changes are relative to the current working draft \cite{N4910}.

\chapter{Acknowledgements}
Many thanks to all of the reviewers and authors of beman/optional26, \cite{The_Beman_Project_beman_optional26}, in particular A. Jiang, Darius Neațu, David Sankel, Eddie Nolan, Jan Kokemüller, Jeff Garland, and River. Tomasz Kamiński provided extensive support for the library wording of optional<T\&>.
Many thanks to all of the reviewers and authors of beman.optional, \cite{The_Beman_Project_beman_optional}, in particular A. Jiang, Darius Neațu, David Sankel, Eddie Nolan, Jan Kokemüller, Jeff Garland, and River. Tomasz Kamiński provided extensive support for the library wording of optional<T\&>.


\chapter*{Document history}
Expand Down
113 changes: 0 additions & 113 deletions src/beman/optional/tests/test_constructor_fail.cpp

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/beman/optional/tests/detail/iterator.t.cpp -*-C++-*-
// tests/beman/optional/detail/iterator.t.cpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

/**
Expand All @@ -7,7 +7,7 @@
#include <beman/optional/detail/iterator.hpp>

#include <gtest/gtest.h>
#include <tests/test_types.hpp>
#include <beman/optional/test_types.hpp>

#include <concepts>
#include <cstdlib>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// src/beman/optional/tests/optional.t.cpp -*-C++-*-
// tests/beman/optional/optional.t.cpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <beman/optional/optional.hpp>

#include <beman/optional/optional.hpp> // test 2nd include OK

#include <beman/optional/tests/test_types.hpp>
#include <beman/optional/test_types.hpp>

#include <functional>
#include <ranges>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// src/beman/optional/tests/optional_constexpr.t.cpp -*-C++-*-
// tests/beman/optional/optional_constexpr.t.cpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <beman/optional/optional.hpp>
#include <beman/optional/tests/test_types.hpp>
#include <beman/optional/tests/test_utilities.hpp>
#include <beman/optional/test_types.hpp>
#include <beman/optional/test_utilities.hpp>

#include <functional>
#include <ranges>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/beman/optional/tests/optional_monadic.t.cpp -*-C++-*-
// tests/beman/optional/optional_monadic.t.cpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <beman/optional/optional.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/beman/optional/tests/optional_range_support.t.cpp -*-C++-*-
// tests/beman/optional/optional_range_support.t.cpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

/**
Expand All @@ -13,7 +13,7 @@
#include <gtest/gtest.h>

#include <beman/optional/detail/iterator.hpp>
#include <beman/optional/tests/test_types.hpp>
#include <beman/optional/test_types.hpp>

#include <algorithm>
#include <concepts>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// src/beman/optional/tests/optional_ref.t.cpp -*-C++-*-
// tests/beman/optional/optional_ref.t.cpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <beman/optional/optional.hpp>
#include <beman/optional/tests/test_types.hpp>
#include <beman/optional/test_types.hpp>

#include <gtest/gtest.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/beman/optional/tests/optional_ref_monadic.t.cpp -*-C++-*-
// tests/beman/optional/optional_ref_monadic.t.cpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <beman/optional/optional.hpp>
Expand Down
112 changes: 112 additions & 0 deletions tests/beman/optional/test_constructor_fail.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// tests/beman/optional/test_constructor_fail.t.cpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <beman/optional/optional.hpp>
#include <string>
#include <utility>

beman::optional::optional<std::string>& makeRefToOptional();
beman::optional::optional<std::string>&& makeRefRefToOptional();

const beman::optional::optional<std::string>& makeCRefToOptional();
const beman::optional::optional<std::string>&& makeCRefRefToOptional();

const beman::optional::optional<std::string&>& makeCRefToOptionalRef();
const beman::optional::optional<std::string&>&& makeCRefRefToOptionalRef();

const beman::optional::optional<std::reference_wrapper<std::string>>& makeCRefToOptionalRefWrap();
const beman::optional::optional<std::reference_wrapper<std::string>>&& makeCRefRefToOptionalRefWrap();

void test_constructors() {
beman::optional::optional<std::string> os;
beman::optional::optional<std::string&> or1 = os;
beman::optional::optional<const std::string&> or2 = os;
beman::optional::optional<std::string> cos;
beman::optional::optional<const std::string&> or3 = cos;

beman::optional::optional<std::string&> or1a{os};
beman::optional::optional<const std::string&> or2a{os};
beman::optional::optional<const std::string&> or3a{cos};

// But disable:
beman::optional::optional<const char*> os2;
beman::optional::optional<const std::string&> or4 = os;
}

void test_constructors_dangling() {
beman::optional::optional<std::string&> os1 = beman::optional::optional<std::string&>();
beman::optional::optional<std::string&> os2 = beman::optional::optional<std::reference_wrapper<std::string>>();

/*
1. std::optional<T> & -> std::optional<T&> / std::optional<T const&> // OK
2. std::optional<T> const& -> std::optional<T const&> / std::optional<T const&> // OK
3. std::optional<T>&& -> std::optional<T&> / std::optional<T const&> // ILL-Formed
4. std::optional<T> const&& -> std::optional<T const&> // ILL-Formed
5. std::optional<T&> cv & -> std::optional<T&> / std::optional<T const&> // OK
6. std::optional<T&> cv && -> std::optional<T&> / std::optional<T const&> // OK
7. std::optional<std::reference_wrapper<T>> cv & -> std::optional<T&> / std::optional<T const&> // OK
8. std::optional<std::reference_wrapper<T>> cv && -> std::optional<T&> / std::optional<T const&> // OK
*/
auto&& t1 = makeRefToOptional(); // std::optional<T> &
static_assert(std::is_same_v<decltype(t1), beman::optional::optional<std::string>&>);
beman::optional::optional<std::string&> o01 = t1;
beman::optional::optional<const std::string&> o02 = t1;

auto&& t2 = makeCRefToOptional(); // std::optional<T> const&
static_assert(std::is_same_v<decltype(t2), const beman::optional::optional<std::string>&>);
// Ill-formed - Diagnosed
beman::optional::optional<std::string&> o03 = t2; // optional is deep const
beman::optional::optional<const std::string&> o04 = t2;

auto&& t3 = makeRefRefToOptional(); // std::optional<T> &&
static_assert(std::is_same_v<decltype(t3), beman::optional::optional<std::string>&&>);
// Ill-formed - Diagnosed
beman::optional::optional<std::string&> o05 = std::move(t3);
// Ill-formed - Diagnosed
beman::optional::optional<const std::string&> o06 = std::move(t3);

auto&& t4 = makeCRefRefToOptional(); // std::optional<T> const&&
static_assert(std::is_same_v<decltype(t4), const beman::optional::optional<std::string>&&>);
// Ill-formed - Diagnosed
beman::optional::optional<std::string&> o07 = std::move(t4);
// Ill-formed - Diagnosed
beman::optional::optional<const std::string&> o07a = std::move(t4);

auto&& t5 = makeCRefToOptionalRef(); // std::optional<T&> const &
static_assert(std::is_same_v<decltype(t5), const beman::optional::optional<std::string&>&>);
beman::optional::optional<std::string&> o08 = t5;
beman::optional::optional<const std::string&> o09 = t5;

auto&& t6 = makeCRefRefToOptionalRef(); // std::optional<T&> const &&
static_assert(std::is_same_v<decltype(t6), const beman::optional::optional<std::string&>&&>);
beman::optional::optional<std::string&> o10 = std::move(t6);
beman::optional::optional<const std::string&> o11 = std::move(t6);

auto&& t7 = makeCRefToOptionalRefWrap(); // std::optional<std::reference_wrapper<T>> cv &
static_assert(std::is_same_v<decltype(t7), const beman::optional::optional<std::reference_wrapper<std::string>>&>);
beman::optional::optional<std::string&> o12 = t7;
beman::optional::optional<const std::string&> o13 = t7;

auto&& t8 = makeCRefRefToOptionalRefWrap(); // std::optional<std::reference_wrapper<T>> cv &&
static_assert(
std::is_same_v<decltype(t8), const beman::optional::optional<std::reference_wrapper<std::string>>&&>);
beman::optional::optional<std::string&> o14 = t8;
beman::optional::optional<const std::string&> o15 = t8;

std::ignore = o01;
std::ignore = o02;
std::ignore = o03;
std::ignore = o04;
std::ignore = o05;
std::ignore = o06;
std::ignore = o07;
std::ignore = o07a;
std::ignore = o08;
std::ignore = o09;
std::ignore = o10;
std::ignore = o11;
std::ignore = o12;
std::ignore = o13;
std::ignore = o14;
std::ignore = o15;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// src/beman/optional/tests/test_types.h -*-C++-*-
// tests/beman/optional/test_types.h -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef BEMAN_OPTIONAL_TESTS_TEST_TYPES_HPP
#define BEMAN_OPTIONAL_TESTS_TEST_TYPES_HPP
#ifndef TESTS_BEMAN_OPTIONAL_TEST_TYPES_HPP
#define TESTS_BEMAN_OPTIONAL_TEST_TYPES_HPP

#include <compare>

Expand Down Expand Up @@ -111,4 +111,4 @@ struct explicitly_convertible_from_const_lvalue_only {

} // namespace beman::optional::tests

#endif // BEMAN_OPTIONAL_TESTS_TEST_TYPES_HPP
#endif // TESTS_BEMAN_OPTIONAL_TEST_TYPES_HPP
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// src/beman/optional/tests/test_utilities.hpp -*-C++-*-
// tests/beman/optional/test_utilities.hpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef BEMAN_OPTIONAL_TESTS_TEST_UTILITIES_HPP
#define BEMAN_OPTIONAL_TESTS_TEST_UTILITIES_HPP
#ifndef TESTS_BEMAN_OPTIONAL_TEST_UTILITIES_HPP
#define TESTS_BEMAN_OPTIONAL_TEST_UTILITIES_HPP

namespace beman::optional::tests {
/***
Expand All @@ -12,4 +12,4 @@ namespace beman::optional::tests {
auto consteval constify(auto expr) { return (expr); }
} // namespace beman::optional::tests

#endif
#endif // TESTS_BEMAN_OPTIONAL_TEST_UTILITIES_HPP

0 comments on commit 711171c

Please sign in to comment.