8000 [MISC] Make literals conditionally constexpr by eseiler · Pull Request #3073 · seqan/seqan3 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[MISC] Make literals conditionally constexpr #3073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ The following API changes should be documented as such:
If possible, provide tooling that performs the changes, e.g. a shell-script.
-->

# 3.3.0

## New features

#### Alphabet
* Improved performance of vector assignment for alphabets ([\#3038](https://github.com/seqan/seqan3/pull/3038)).
* Improved performance of `seqan3::dna4::complement()` ([\#3026](https://github.com/seqan/seqan3/pull/3026)).
* Char literals returning std::vector are now constexpr if supported by the compiler
([\#3073](https://github.com/seqan/seqan3/pull/3073)).

## Notable Bug-fixes

## API changes

#### Dependencies
* We require at least CMake 3.16 for our test suite. Note that the minimum requirement for using SeqAn3 is unchanged
([\#3050](https://github.com/seqan/seqan3/pull/3050)).

# 3.2.0

## New features
Expand All @@ -32,8 +50,6 @@ If possible, provide tooling that performs the changes, e.g. a shell-script.
* `seqan3::cigar` can now be assigned from `std::string_view` ([\#2966](https://github.com/seqan/seqan3/pull/2966)).
* Added `seqan3::views::char_strictly_to`. Behaves l 8000 ike `seqan3::views::char_to`, but throws on invalid
input ([\#2898](https://github.com/seqan/seqan3/pull/2898)).
* Improved performance of vector assignment for alphabets ([\#3038](https://github.com/seqan/seqan3/pull/3038)).
* Improved performance of `seqan3::dna4::complement()` ([\#3026](https://github.com/seqan/seqan3/pull/3026)).

#### I/O
* Added `seqan3::sequence_file_option::fasta_ignore_blanks_before_id` to ignore blanks before IDs when reading FASTA
Expand Down Expand Up @@ -120,8 +136,6 @@ deprecated. Please keep this in mind if you encounter errors with `seqan3::views

#### Dependencies
* We now use Doxygen version 1.9.4 to build our documentation ([\#2979](https://github.com/seqan/seqan3/pull/2979)).
* We require at least CMake 3.16 for our test suite. Note that the minimum requirement for using SeqAn3 is unchanged
([\#3050](https://github.com/seqan/seqan3/pull/3050)).
* Removed range-v3 ([\#2998](https://github.com/seqan/seqan3/pull/2998)).
* Updated cereal to 1.3.2 ([\#3012](https://github.com/seqan/seqan3/pull/3012)).
* Updated sdsl-lite to 3.0.1 ([\#3012](https://github.com/seqan/seqan3/pull/3012)).
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/aminoacid/aa10li.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ constexpr aa10li operator""_aa10li(char const c) noexcept
*
* \stableapi{Since version 3.1.}
*/
inline aa10li_vector operator""_aa10li(char const * const s, size_t const n)
SEQAN3_WORKAROUND_LITERAL aa10li_vector operator""_aa10li(char const * const s, size_t const n)
{
aa10li_vector r;
r.resize(n);
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/aminoacid/aa10murphy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ constexpr aa10murphy operator""_aa10murphy(char const c) noexcept
*
* \stableapi{Since version 3.1.}
*/
inline aa10murphy_vector operator""_aa10murphy(char const * const s, size_t const n)
SEQAN3_WORKAROUND_LITERAL aa10murphy_vector operator""_aa10murphy(char const * const s, size_t const n)
{
aa10murphy_vector r;
r.resize(n);
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/aminoacid/aa20.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ constexpr aa20 operator""_aa20(char const c) noexcept
*
* \stableapi{Since version 3.1.}
*/
inline aa20_vector operator""_aa20(char const * const s, size_t const n)
SEQAN3_WORKAROUND_LITERAL aa20_vector operator""_aa20(char const * const s, size_t const n)
{
aa20_vector r;
r.resize(n);
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/aminoacid/aa27.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ constexpr aa27 operator""_aa27(char const c) noexcept
*
* \stableapi{Since version 3.1.}
*/
inline aa27_vector operator""_aa27(char const * const s, size_t const n)
SEQAN3_WORKAROUND_LITERAL aa27_vector operator""_aa27(char const * const s, size_t const n)
{
aa27_vector r;
r.resize(n);
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/nucleotide/dna15.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ constexpr dna15 operator""_dna15(char const c) noexcept
*
* \stableapi{Since version 3.1.}
*/
inline dna15_vector operator""_dna15(char const * s, std::size_t n)
SEQAN3_WORKAROUND_LITERAL dna15_vector operator""_dna15(char const * s, std::size_t n)
{
dna15_vector r;
r.resize(n);
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/nucleotide/dna16sam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ constexpr dna16sam operator""_dna16sam(char const c) noexcept
*
* \stableapi{Since version 3.1.}
*/
inline dna16sam_vector operator""_dna16sam(char const * s, size_t n)
SEQAN3_WORKAROUND_LITERAL dna16sam_vector operator""_dna16sam(char const * s, size_t n)
{
dna16sam_vector r;
r.resize(n);
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/nucleotide/dna3bs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ constexpr dna3bs operator""_dna3bs(char const c) noexcept
*
* \stableapi{Since version 3.1.}
*/
inline dna3bs_vector operator""_dna3bs(char const * s, std::size_t n)
SEQAN3_WORKAROUND_LITERAL dna3bs_vector operator""_dna3bs(char const * s, std::size_t n)
{
dna3bs_vector r;
r.resize(n);
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/nucleotide/dna4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ constexpr dna4 operator""_dna4(char const c) noexcept
*
* \stableapi{Since version 3.1.}
*/
inline dna4_vector operator""_dna4(char const * s, std::size_t n)
SEQAN3_WORKAROUND_LITERAL dna4_vector operator""_dna4(char const * s, std::size_t n)
{
dna4_vector r;
r.resize(n);
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/nucleotide/dna5.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ constexpr dna5 operator""_dna5(char const c) noexcept
*
* \stableapi{Since version 3.1.}
*/
inline dna5_vector operator""_dna5(char const * s, std::size_t n)
SEQAN3_WORKAROUND_LITERAL dna5_vector operator""_dna5(char const * s, std::size_t n)
{
dna5_vector r;
r.resize(n);
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/nucleotide/rna15.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ constexpr rna15 operator""_rna15(char const c) noexcept
*
* \stableapi{Since version 3.1.}
*/
inline rna15_vector operator""_rna15(char const * s, std::size_t n)
SEQAN3_WORKAROUND_LITERAL rna15_vector operator""_rna15(char const * s, std::size_t n)
{
rna15_vector r;
r.resize(n);
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/nucleotide/rna4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ constexpr rna4 operator""_rna4(char const c) noexcept
*
* \stableapi{Since version 3.1.}
*/
inline rna4_vector operator""_rna4(char const * s, std::size_t n)
SEQAN3_WORKAROUND_LITERAL rna4_vector operator""_rna4(char const * s, std::size_t n)
{
rna4_vector r;
r.resize(n);
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/nucleotide/rna5.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ constexpr rna5 operator""_rna5(char const c) noexcept
*
* \stableapi{Since version 3.1.}
*/
inline rna5_vector operator""_rna5(char const * s, std::size_t n)
SEQAN3_WORKAROUND_LITERAL rna5_vector operator""_rna5(char const * s, std::size_t n)
{
rna5_vector r;
r.resize(n);
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/quality/phred42.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ constexpr phred42 operator""_phred42(char const c) noexcept
*
* \stableapi{Since version 3.1.}
*/
inline std::vector<phred42> operator""_phred42(char const * s, std::size_t n)
SEQAN3_WORKAROUND_LITERAL std::vector<phred42> operator""_phred42(char const * s, std::size_t n)
{
std::vector<phred42> r;
r.resize(n);
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/quality/phred63.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ constexpr phred63 operator""_phred63(char const c) noexcept
*
* \stableapi{Since version 3.1.}
*/
inline std::vector<phred63> operator""_phred63(char const * s, std::size_t n)
SEQAN3_WORKAROUND_LITERAL std::vector<phred63> operator""_phred63(char const * s, std::size_t n)
{
std::vector<phred63> r;
r.resize(n);
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/quality/phred68solexa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ constexpr phred68solexa operator""_phred68solexa(char const c) noexcept
*
* \stableapi{Since version 3.1.}
*/
inline std::vector<phred68solexa> operator""_phred68solexa(char const * s, std::size_t n)
SEQAN3_WORKAROUND_LITERAL std::vector<phred68solexa> operator""_phred68solexa(char const * s, std::size_t n)
{
std::vector<phred68solexa> r;
r.resize(n);
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/quality/phred94.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ constexpr phred94 operator""_phred94(char const c) noexcept
*
* \stableapi{Since version 3.1.}
*/
inline std::vector<phred94> operator""_phred94(char const * s, std::size_t n)
SEQAN3_WORKAROUND_LITERAL std::vector<phred94> operator""_phred94(char const * s, std::size_t n)
{
std::vector<phred94> r;
r.resize(n);
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/structure/dot_bracket3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ constexpr dot_bracket3 operator""_db3(char const ch) noexcept
*
* \experimentalapi{Experimental since version 3.1.}
*/
inline std::vector<dot_bracket3> operator""_db3(char const * str, std::size_t len)
SEQAN3_WORKAROUND_LITERAL std::vector<dot_bracket3> operator""_db3(char const * str, std::size_t len)
{
std::vector<dot_bracket3> vec;
vec.resize(len);
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/structure/dssp9.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ constexpr dssp9 operator""_dssp9(char const ch) noexcept
*
* \experimentalapi{Experimental since version 3.1.}
*/
inline std::vector<dssp9> operator""_dssp9(char const * str, std::size_t len)
SEQAN3_WORKAROUND_LITERAL std::vector<dssp9> operator""_dssp9(char const * str, std::size_t len)
{
std::vector<dssp9> vec;
vec.resize(len);
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/structure/wuss.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ constexpr wuss51 operator""_wuss51(char const ch) noexcept
*
* \experimentalapi{Experimental since version 3.1.}
*/
inline std::vector<wuss51> operator""_wuss51(char const * str, std::size_t len)
SEQAN3_WORKAROUND_LITERAL std::vector<wuss51> operator""_wuss51(char const * str, std::size_t len)
{
std::vector<wuss51> vec;
vec.resize(len);
Expand Down
7 changes: 7 additions & 0 deletions include/seqan3/core/platform.hpp
Original file line number Diff line number Diff line change
Ex 10000 pand Up @@ -273,6 +273,13 @@ static_assert(sdsl::sdsl_version_major == 3, "Only version 3 of the SDSL is supp
# endif
#endif

//!\brief Our char literals returning std::vector should be constexpr if constexpr std::vector is supported.
#if defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L
# define SEQAN3_WORKAROUND_LITERAL constexpr
#else
# define SEQAN3_WORKAROUND_LITERAL inline
#endif

#if SEQAN3_DOXYGEN_ONLY(1) 0
//!\brief This disables the warning you would get if -D_GLIBCXX_USE_CXX11_ABI=0 is set.
# define SEQAN3_DISABLE_LEGACY_STD_DIAGNOSTIC
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/io/sam_file/detail/cigar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ inline void update_alignment_lengths(int32_t & ref_length,
* `{[(H,1), (M,4), (D,1), (M,2), (S,2)], 7, 6}`.
*/
template <typename cigar_input_type>
inline std::tuple<std::vector<cigar>, int32_t, int32_t> parse_cigar(cigar_input_type && cigar_input)
SEQAN3_WORKAROUND_LITERAL std::tuple<std::vector<cigar>, int32_t, int32_t> parse_cigar(cigar_input_type && cigar_input)
{
std::vector<cigar> operations{};
std::array<char, 20> buffer{}; // buffer to parse numbers with from_chars. Biggest number should fit in uint64_t
Expand Down
3 changes: 2 additions & 1 deletion test/documentation/seqan3_doxygen_cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ PREDEFINED = "CEREAL_SERIALIZE_FUNCTION_NAME=serialize" \
"CEREAL_SAVE_MINIMAL_FUNCTION_NAME=save_minimal" \
"SEQAN3_DOXYGEN_ONLY(x)= x" \
"${SEQAN3_DOXYGEN_PREDEFINED_NDEBUG}" \
"__cpp_lib_three_way_comparison=1"
"__cpp_lib_three_way_comparison=1" \
"SEQAN3_WORKAROUND_LITERAL=constexpr"

EXPAND_AS_DEFINED = SEQAN3_CPO_OVERLOAD_BODY SEQAN3_CPO_OVERLOAD

Expand Down
2 changes: 1 addition & 1 deletion test/include/seqan3/test/literal/cigar_literal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace seqan3::test
{

inline std::vector<cigar> operator""_cigar(char const * s, std::size_t n)
SEQAN3_WORKAROUND_LITERAL std::vector<cigar> operator""_cigar(char const * s, std::size_t n)
{
return std::get<0>(seqan3::detail::parse_cigar(std::string_view{s, n}));
}
Expand Down
3 changes: 2 additions & 1 deletion test/include/seqan3/test/literal/gapped_dna5_literal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
namespace seqan3::test
{

inline std::vector<seqan3::gapped<seqan3::dna5>> operator""_gapped_dna5(char const * s, std::size_t n)
SEQAN3_WORKAROUND_LITERAL std::vector<seqan3::gapped<seqan3::dna5>> operator""_gapped_dna5(char const * s,
std::size_t n)
{
std::vector<seqan3::gapped<seqan3::dna5>> r;
r.resize(n);
Expand Down
0