From 8ef58676d6338d6f57281c652faa0e48f64afd0d Mon Sep 17 00:00:00 2001 From: Alexander Hans Date: Mon, 12 May 2025 09:59:19 +0200 Subject: [PATCH 01/32] chore: unify include guards to #pragma once (#975) [no important files changed] --- bin/make-stub-files.sh | 4 +--- exercises/practice/acronym/.meta/example.h | 5 +---- exercises/practice/acronym/acronym.h | 5 +---- exercises/practice/all-your-base/.meta/example.h | 5 +---- exercises/practice/all-your-base/all_your_base.h | 5 +---- exercises/practice/allergies/.meta/example.h | 5 +---- exercises/practice/allergies/allergies.h | 5 +---- exercises/practice/anagram/.meta/example.h | 5 +---- exercises/practice/anagram/anagram.h | 5 +---- exercises/practice/armstrong-numbers/.meta/example.h | 5 +---- .../practice/armstrong-numbers/armstrong_numbers.h | 5 +---- exercises/practice/atbash-cipher/.meta/example.h | 4 +--- exercises/practice/atbash-cipher/atbash_cipher.h | 5 +---- exercises/practice/bank-account/.meta/example.h | 4 +--- exercises/practice/bank-account/bank_account.h | 5 +---- exercises/practice/beer-song/.meta/example.h | 5 +---- exercises/practice/beer-song/beer_song.h | 5 +---- exercises/practice/binary-search-tree/.meta/example.h | 5 +---- .../practice/binary-search-tree/binary_search_tree.h | 5 +---- .../practice/binary-search/.approaches/introduction.md | 4 +--- .../.approaches/while-with-if-statements/content.md | 4 +--- exercises/practice/binary-search/.meta/example.h | 5 +---- exercises/practice/binary-search/binary_search.h | 5 +---- exercises/practice/binary/.meta/example.h | 5 +---- exercises/practice/binary/binary.h | 5 +---- exercises/practice/bob/.meta/example.h | 5 +---- exercises/practice/bob/bob.h | 5 +---- exercises/practice/circular-buffer/.meta/example.h | 5 +---- exercises/practice/circular-buffer/circular_buffer.h | 5 +---- exercises/practice/clock/.meta/example.h | 5 +---- exercises/practice/clock/clock.h | 5 +---- exercises/practice/collatz-conjecture/.meta/example.h | 5 +---- .../practice/collatz-conjecture/collatz_conjecture.h | 5 +---- exercises/practice/complex-numbers/.meta/example.h | 5 +---- exercises/practice/complex-numbers/complex_numbers.h | 5 +---- exercises/practice/crypto-square/.meta/example.h | 5 +---- exercises/practice/crypto-square/crypto_square.h | 5 +---- exercises/practice/darts/.meta/example.h | 5 +---- exercises/practice/darts/darts.h | 5 +---- .../practice/difference-of-squares/.meta/example.h | 5 +---- .../difference-of-squares/difference_of_squares.h | 5 +---- exercises/practice/etl/.meta/example.h | 5 +---- exercises/practice/etl/etl.h | 5 +---- exercises/practice/food-chain/.meta/example.h | 5 +---- exercises/practice/food-chain/food_chain.h | 5 +---- exercises/practice/gigasecond/.meta/example.h | 5 +---- exercises/practice/gigasecond/gigasecond.h | 5 +---- exercises/practice/grade-school/.meta/example.h | 5 +---- exercises/practice/grade-school/grade_school.h | 5 +---- exercises/practice/grains/.meta/example.h | 5 +---- exercises/practice/grains/grains.h | 5 +---- exercises/practice/hamming/.meta/example.h | 5 +---- exercises/practice/hamming/hamming.h | 5 +---- exercises/practice/hexadecimal/.meta/example.h | 5 +---- exercises/practice/hexadecimal/hexadecimal.h | 5 +---- exercises/practice/isbn-verifier/.meta/example.h | 5 +---- exercises/practice/isbn-verifier/isbn_verifier.h | 5 +---- exercises/practice/isogram/.meta/example.h | 4 +--- exercises/practice/isogram/isogram.h | 5 +---- exercises/practice/knapsack/.meta/example.h | 5 +---- exercises/practice/knapsack/knapsack.h | 5 +---- .../practice/largest-series-product/.meta/example.h | 5 +---- .../largest-series-product/largest_series_product.h | 5 +---- exercises/practice/leap/.meta/example.h | 5 +---- exercises/practice/leap/leap.h | 5 +---- exercises/practice/luhn/.meta/example.h | 5 +---- exercises/practice/luhn/luhn.h | 5 +---- exercises/practice/matching-brackets/.meta/example.h | 5 +---- .../practice/matching-brackets/matching_brackets.h | 5 +---- exercises/practice/meetup/.meta/example.h | 5 +---- exercises/practice/meetup/meetup.h | 5 +---- exercises/practice/nth-prime/.meta/example.h | 5 +---- exercises/practice/nth-prime/nth_prime.h | 5 +---- exercises/practice/nucleotide-count/.meta/example.h | 5 +---- exercises/practice/nucleotide-count/nucleotide_count.h | 5 +---- .../pangram/.approaches/algorithm-allof/content.md | 5 +---- .../practice/pangram/.approaches/bitset-all/content.md | 5 +---- exercises/practice/pangram/.approaches/introduction.md | 5 +---- exercises/practice/pangram/.meta/example.h | 4 +--- exercises/practice/pangram/pangram.h | 5 +---- .../practice/parallel-letter-frequency/.meta/example.h | 5 +---- .../parallel_letter_frequency.h | 5 +---- exercises/practice/pascals-triangle/.meta/example.h | 5 +---- exercises/practice/pascals-triangle/pascals_triangle.h | 5 +---- exercises/practice/perfect-numbers/.meta/example.h | 5 +---- exercises/practice/perfect-numbers/perfect_numbers.h | 5 +---- exercises/practice/phone-number/.meta/example.h | 5 +---- exercises/practice/phone-number/phone_number.h | 5 +---- exercises/practice/prime-factors/.meta/example.h | 5 +---- exercises/practice/prime-factors/prime_factors.h | 5 +---- exercises/practice/protein-translation/.meta/example.h | 5 +---- .../practice/protein-translation/protein_translation.h | 5 +---- exercises/practice/queen-attack/.meta/example.h | 5 +---- exercises/practice/queen-attack/queen_attack.h | 5 +---- exercises/practice/raindrops/.meta/example.h | 5 +---- exercises/practice/raindrops/raindrops.h | 5 +---- .../.approaches/direct-construction/content.md | 5 +---- .../.approaches/divide-and-conquer/content.md | 5 +---- .../reverse-string/.approaches/iterative/content.md | 5 +---- .../.approaches/linear-recursion/content.md | 5 +---- .../.approaches/over-engineered/content.md | 5 +---- .../.approaches/stack-operations/content.md | 5 +---- .../.approaches/swapping-characters/content.md | 5 +---- .../.approaches/using-the-standard-lib/content.md | 5 +---- exercises/practice/reverse-string/.meta/example.h | 5 +---- exercises/practice/reverse-string/reverse_string.h | 5 +---- exercises/practice/rna-transcription/.meta/example.h | 5 +---- .../practice/rna-transcription/rna_transcription.h | 5 +---- exercises/practice/robot-name/.meta/example.h | 5 +---- exercises/practice/robot-name/robot_name.h | 5 +---- exercises/practice/robot-simulator/.meta/example.h | 5 +---- exercises/practice/robot-simulator/robot_simulator.h | 5 +---- exercises/practice/roman-numerals/.meta/example.h | 5 +---- exercises/practice/roman-numerals/roman_numerals.h | 5 +---- exercises/practice/say/.meta/example.h | 5 +---- exercises/practice/say/say.h | 5 +---- exercises/practice/scrabble-score/.meta/example.h | 5 +---- exercises/practice/scrabble-score/scrabble_score.h | 5 +---- .../.approaches/if-statements-with-reverse/content.md | 5 +---- .../secret-handshake/.approaches/introduction.md | 10 ++-------- .../.approaches/iterate-once/content.md | 5 +---- exercises/practice/secret-handshake/.meta/example.h | 5 +---- exercises/practice/secret-handshake/secret_handshake.h | 5 +---- exercises/practice/series/.meta/example.h | 5 +---- exercises/practice/series/series.h | 5 +---- exercises/practice/sieve/.approaches/introduction.md | 4 +--- .../sieve/.approaches/vector-of-bools/content.md | 4 +--- exercises/practice/sieve/.meta/example.h | 5 +---- exercises/practice/sieve/sieve.h | 5 +---- exercises/practice/simple-linked-list/.meta/example.h | 5 +---- .../practice/simple-linked-list/simple_linked_list.h | 5 +---- exercises/practice/space-age/.meta/example.h | 5 +---- exercises/practice/space-age/space_age.h | 5 +---- exercises/practice/spiral-matrix/.meta/example.h | 5 +---- exercises/practice/spiral-matrix/spiral_matrix.h | 5 +---- exercises/practice/sum-of-multiples/.meta/example.h | 5 +---- exercises/practice/sum-of-multiples/sum_of_multiples.h | 5 +---- exercises/practice/triangle/.meta/example.h | 5 +---- exercises/practice/triangle/triangle.h | 5 +---- exercises/practice/trinary/.meta/example.h | 5 +---- exercises/practice/trinary/trinary.h | 5 +---- exercises/practice/two-bucket/.meta/example.h | 5 +---- exercises/practice/two-bucket/two_bucket.h | 5 +---- exercises/practice/two-fer/.meta/example.h | 5 +---- exercises/practice/two-fer/two_fer.h | 5 +---- exercises/practice/word-count/.meta/example.h | 5 +---- exercises/practice/word-count/word_count.h | 5 +---- exercises/practice/zebra-puzzle/.meta/example.h | 5 +---- exercises/practice/zebra-puzzle/zebra_puzzle.h | 5 +---- reference/exercise-concepts/anagram.md | 5 +---- reference/exercise-concepts/grains.md | 5 +---- reference/exercise-concepts/hamming.md | 5 +---- reference/exercise-concepts/isogram.md | 5 +---- reference/exercise-concepts/leap.md | 5 +---- reference/exercise-concepts/pangram.md | 5 +---- reference/exercise-concepts/raindrops.md | 5 +---- reference/exercise-concepts/reverse-string.md | 5 +---- reference/exercise-concepts/rna-transcription.md | 5 +---- reference/exercise-concepts/scrabble-score.md | 5 +---- reference/exercise-concepts/sieve.md | 5 +---- reference/exercise-concepts/space-age.md | 5 +---- reference/exercise-concepts/sum-of-multiples.md | 5 +---- reference/exercise-concepts/triangle.md | 5 +---- reference/exercise-concepts/trinary.md | 5 +---- reference/exercise-concepts/two-fer.md | 5 +---- reference/exercise-concepts/word-count.md | 5 +---- 166 files changed, 167 insertions(+), 659 deletions(-) diff --git a/bin/make-stub-files.sh b/bin/make-stub-files.sh index e38ddc880..76eab0b27 100755 --- a/bin/make-stub-files.sh +++ b/bin/make-stub-files.sh @@ -21,10 +21,8 @@ for exercise_dir in "${exercises_dir}"/*; do header="$exercise_name.h" source="$exercise_name.cpp" if ! test -f "$header"; then - printf "#if !defined(${exercise_name^^}_H)\n" >> $header - printf "#define ${exercise_name^^}_H\n" >> $header + printf "#pragma once\n" >> $header printf "\nnamespace $exercise_name {\n\n} // namespace $exercise_name\n" >> $header - printf "\n#endif // ${exercise_name^^}_H" >> $header git add $header fi if ! test -f "$source"; then diff --git a/exercises/practice/acronym/.meta/example.h b/exercises/practice/acronym/.meta/example.h index 337c77ce0..ec7e4952f 100644 --- a/exercises/practice/acronym/.meta/example.h +++ b/exercises/practice/acronym/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(ACRONYM_H) -#define ACRONYM_H +#pragma once #include @@ -8,5 +7,3 @@ namespace acronym { std::string acronym(std::string const&); } - -#endif diff --git a/exercises/practice/acronym/acronym.h b/exercises/practice/acronym/acronym.h index 85b9b2a28..c0539a3c6 100644 --- a/exercises/practice/acronym/acronym.h +++ b/exercises/practice/acronym/acronym.h @@ -1,10 +1,7 @@ -#if !defined(ACRONYM_H) -#define ACRONYM_H +#pragma once namespace acronym { // TODO: add your solution here } // namespace acronym - -#endif // ACRONYM_H \ No newline at end of file diff --git a/exercises/practice/all-your-base/.meta/example.h b/exercises/practice/all-your-base/.meta/example.h index 77bb8015b..73fc87240 100644 --- a/exercises/practice/all-your-base/.meta/example.h +++ b/exercises/practice/all-your-base/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(ALL_YOUR_BASE_H) -#define ALL_YOUR_BASE_H +#pragma once #include @@ -9,5 +8,3 @@ std::vector convert(unsigned int input_base, const std::vector& input_digits, unsigned int output_base); } - -#endif diff --git a/exercises/practice/all-your-base/all_your_base.h b/exercises/practice/all-your-base/all_your_base.h index a2b6cfab3..408a1475f 100644 --- a/exercises/practice/all-your-base/all_your_base.h +++ b/exercises/practice/all-your-base/all_your_base.h @@ -1,10 +1,7 @@ -#if !defined(ALL_YOUR_BASE_H) -#define ALL_YOUR_BASE_H +#pragma once namespace all_your_base { // TODO: add your solution here } // namespace all_your_base - -#endif // ALL_YOUR_BASE_H \ No newline at end of file diff --git a/exercises/practice/allergies/.meta/example.h b/exercises/practice/allergies/.meta/example.h index cb03d6eaf..3d7c372e0 100644 --- a/exercises/practice/allergies/.meta/example.h +++ b/exercises/practice/allergies/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(ALLERGIES_H) -#define ALLERGIES_H +#pragma once #include #include @@ -23,5 +22,3 @@ class allergy_test { }; } // namespace allergies - -#endif diff --git a/exercises/practice/allergies/allergies.h b/exercises/practice/allergies/allergies.h index 95573e4a6..7a8097561 100644 --- a/exercises/practice/allergies/allergies.h +++ b/exercises/practice/allergies/allergies.h @@ -1,10 +1,7 @@ -#if !defined(ALLERGIES_H) -#define ALLERGIES_H +#pragma once namespace allergies { // TODO: add your solution here } // namespace allergies - -#endif // ALLERGIES_H \ No newline at end of file diff --git a/exercises/practice/anagram/.meta/example.h b/exercises/practice/anagram/.meta/example.h index a6c63b643..10ea84404 100644 --- a/exercises/practice/anagram/.meta/example.h +++ b/exercises/practice/anagram/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(ANAGRAM_H) -#define ANAGRAM_H +#pragma once #include #include @@ -18,5 +17,3 @@ class anagram { }; } // namespace anagram - -#endif diff --git a/exercises/practice/anagram/anagram.h b/exercises/practice/anagram/anagram.h index 540d9e5e5..3b3c1d51b 100644 --- a/exercises/practice/anagram/anagram.h +++ b/exercises/practice/anagram/anagram.h @@ -1,10 +1,7 @@ -#if !defined(ANAGRAM_H) -#define ANAGRAM_H +#pragma once namespace anagram { // TODO: add your solution here } // namespace anagram - -#endif // ANAGRAM_H \ No newline at end of file diff --git a/exercises/practice/armstrong-numbers/.meta/example.h b/exercises/practice/armstrong-numbers/.meta/example.h index 1ac6f08ee..4b678af5b 100644 --- a/exercises/practice/armstrong-numbers/.meta/example.h +++ b/exercises/practice/armstrong-numbers/.meta/example.h @@ -1,10 +1,7 @@ -#if !defined(ARMSTRONG_NUMBERS_H_) -#define ARMSTRONG_NUMBERS_H_ +#pragma once namespace armstrong_numbers { bool is_armstrong_number(int number); } // namespace armstrong_numbers - -#endif // !ARMSTRONG_NUMBERS_H_ \ No newline at end of file diff --git a/exercises/practice/armstrong-numbers/armstrong_numbers.h b/exercises/practice/armstrong-numbers/armstrong_numbers.h index b6bc55a97..f3907dbfc 100644 --- a/exercises/practice/armstrong-numbers/armstrong_numbers.h +++ b/exercises/practice/armstrong-numbers/armstrong_numbers.h @@ -1,10 +1,7 @@ -#if !defined(ARMSTRONG_NUMBERS_H) -#define ARMSTRONG_NUMBERS_H +#pragma once namespace armstrong_numbers { // TODO: add your solution here } // namespace armstrong_numbers - -#endif // ARMSTRONG_NUMBERS_H \ No newline at end of file diff --git a/exercises/practice/atbash-cipher/.meta/example.h b/exercises/practice/atbash-cipher/.meta/example.h index 0c0f36754..7bc7a4e3e 100644 --- a/exercises/practice/atbash-cipher/.meta/example.h +++ b/exercises/practice/atbash-cipher/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(ATBASH_CIPHER_H) -#define ATBASH_CIPHER_H +#pragma once #include @@ -9,4 +8,3 @@ std::string encode(std::string const& plaintext); std::string decode(std::string const& ciphertext); } // namespace atbash_cipher -#endif diff --git a/exercises/practice/atbash-cipher/atbash_cipher.h b/exercises/practice/atbash-cipher/atbash_cipher.h index b744d829a..7f3d41ba2 100644 --- a/exercises/practice/atbash-cipher/atbash_cipher.h +++ b/exercises/practice/atbash-cipher/atbash_cipher.h @@ -1,10 +1,7 @@ -#if !defined(ATBASH_CIPHER_H) -#define ATBASH_CIPHER_H +#pragma once namespace atbash_cipher { // TODO: add your solution here } // namespace atbash_cipher - -#endif // ATBASH_CIPHER_H \ No newline at end of file diff --git a/exercises/practice/bank-account/.meta/example.h b/exercises/practice/bank-account/.meta/example.h index a2e1da38f..6b9a76617 100644 --- a/exercises/practice/bank-account/.meta/example.h +++ b/exercises/practice/bank-account/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(BANK_ACCOUNT_H) -#define BANK_ACCOUNT_H +#pragma once #include @@ -21,4 +20,3 @@ class Bankaccount { std::mutex mutex_{}; }; } // namespace Bankaccount -#endif // BANK_ACCOUNT_H \ No newline at end of file diff --git a/exercises/practice/bank-account/bank_account.h b/exercises/practice/bank-account/bank_account.h index 048f65ec9..e133784fa 100644 --- a/exercises/practice/bank-account/bank_account.h +++ b/exercises/practice/bank-account/bank_account.h @@ -1,9 +1,6 @@ -#if !defined(BANK_ACCOUNT_H) -#define BANK_ACCOUNT_H +#pragma once namespace Bankaccount { class Bankaccount {}; // class Bankaccount } // namespace Bankaccount - -#endif // BANK_ACCOUNT_H \ No newline at end of file diff --git a/exercises/practice/beer-song/.meta/example.h b/exercises/practice/beer-song/.meta/example.h index fdc47dc2b..5cc7bc54a 100644 --- a/exercises/practice/beer-song/.meta/example.h +++ b/exercises/practice/beer-song/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(BEER_SONG_H) -#define BEER_SONG_H +#pragma once #include @@ -10,5 +9,3 @@ std::string sing(unsigned begin, unsigned end); std::string sing(unsigned bottles); } // namespace beer_song - -#endif diff --git a/exercises/practice/beer-song/beer_song.h b/exercises/practice/beer-song/beer_song.h index e6750570d..72767b37d 100644 --- a/exercises/practice/beer-song/beer_song.h +++ b/exercises/practice/beer-song/beer_song.h @@ -1,10 +1,7 @@ -#if !defined(BEER_SONG_H) -#define BEER_SONG_H +#pragma once namespace beer_song { // TODO: add your solution here } // namespace beer_song - -#endif // BEER_SONG_H \ No newline at end of file diff --git a/exercises/practice/binary-search-tree/.meta/example.h b/exercises/practice/binary-search-tree/.meta/example.h index d0ad7afbe..6aa2ced35 100644 --- a/exercises/practice/binary-search-tree/.meta/example.h +++ b/exercises/practice/binary-search-tree/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(_BINARY_SEARCH_TREE_H_) -#define _BINARY_SEARCH_TREE_H_ +#pragma once #include #include @@ -211,5 +210,3 @@ void binary_tree::binary_tree_iter::advance_branch_iter(state next_state) { } } // namespace binary_search_tree - -#endif // _BINARY_SEARCH_TREE_H_ diff --git a/exercises/practice/binary-search-tree/binary_search_tree.h b/exercises/practice/binary-search-tree/binary_search_tree.h index ae0c1dc4a..ec108e617 100644 --- a/exercises/practice/binary-search-tree/binary_search_tree.h +++ b/exercises/practice/binary-search-tree/binary_search_tree.h @@ -1,10 +1,7 @@ -#if !defined(BINARY_SEARCH_TREE_H) -#define BINARY_SEARCH_TREE_H +#pragma once namespace binary_search_tree { // TODO: add your solution here } // namespace binary_search_tree - -#endif // BINARY_SEARCH_TREE_H \ No newline at end of file diff --git a/exercises/practice/binary-search/.approaches/introduction.md b/exercises/practice/binary-search/.approaches/introduction.md index e2aef794c..b15965483 100644 --- a/exercises/practice/binary-search/.approaches/introduction.md +++ b/exercises/practice/binary-search/.approaches/introduction.md @@ -7,14 +7,12 @@ One approach can use a `while` loop with `if` statements. **binary_search.h** ```cpp -#if !defined(BINARY_SEARCH_H) -#define BINARY_SEARCH_H +#pragma once #include #include namespace binary_search { std::size_t find (const std::vector& data, int value); } // namespace binary_search -#endif // BINARY_SEARCH_H ``` **binary_search.cpp** diff --git a/exercises/practice/binary-search/.approaches/while-with-if-statements/content.md b/exercises/practice/binary-search/.approaches/while-with-if-statements/content.md index 7a9d4bac8..8fe0ef062 100644 --- a/exercises/practice/binary-search/.approaches/while-with-if-statements/content.md +++ b/exercises/practice/binary-search/.approaches/while-with-if-statements/content.md @@ -3,14 +3,12 @@ **binary_search.h** ```cpp -#if !defined(BINARY_SEARCH_H) -#define BINARY_SEARCH_H +#pragma once #include #include namespace binary_search { std::size_t find (const std::vector& data, int value); } // namespace binary_search -#endif // BINARY_SEARCH_H ``` **binary_search.cpp** diff --git a/exercises/practice/binary-search/.meta/example.h b/exercises/practice/binary-search/.meta/example.h index 3b1566634..f0d031228 100644 --- a/exercises/practice/binary-search/.meta/example.h +++ b/exercises/practice/binary-search/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(BINARY_SEARCH_H) -#define BINARY_SEARCH_H +#pragma once #include #include @@ -11,5 +10,3 @@ using std::size_t; size_t find(std::vector const&, int const); } // namespace binary_search - -#endif // BINARY_SEARCH_H diff --git a/exercises/practice/binary-search/binary_search.h b/exercises/practice/binary-search/binary_search.h index eee1c0e59..40b66bc95 100644 --- a/exercises/practice/binary-search/binary_search.h +++ b/exercises/practice/binary-search/binary_search.h @@ -1,10 +1,7 @@ -#if !defined(BINARY_SEARCH_H) -#define BINARY_SEARCH_H +#pragma once namespace binary_search { // TODO: add your solution here } // namespace binary_search - -#endif // BINARY_SEARCH_H \ No newline at end of file diff --git a/exercises/practice/binary/.meta/example.h b/exercises/practice/binary/.meta/example.h index 21c838218..a33dff88d 100644 --- a/exercises/practice/binary/.meta/example.h +++ b/exercises/practice/binary/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(BINARY_H) -#define BINARY_H +#pragma once #include @@ -8,5 +7,3 @@ namespace binary { int convert(std::string const& text); } - -#endif diff --git a/exercises/practice/binary/binary.h b/exercises/practice/binary/binary.h index 714bb5d11..a8e5dc7a2 100644 --- a/exercises/practice/binary/binary.h +++ b/exercises/practice/binary/binary.h @@ -1,10 +1,7 @@ -#if !defined(BINARY_H) -#define BINARY_H +#pragma once namespace binary { // TODO: add your solution here } // namespace binary - -#endif // BINARY_H \ No newline at end of file diff --git a/exercises/practice/bob/.meta/example.h b/exercises/practice/bob/.meta/example.h index 7a2d57a16..9cab86455 100644 --- a/exercises/practice/bob/.meta/example.h +++ b/exercises/practice/bob/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(BOB_H) -#define BOB_H +#pragma once #include @@ -8,5 +7,3 @@ namespace bob { std::string hey(std::string const& text); } - -#endif diff --git a/exercises/practice/bob/bob.h b/exercises/practice/bob/bob.h index 5b0abf335..3f33c05a8 100644 --- a/exercises/practice/bob/bob.h +++ b/exercises/practice/bob/bob.h @@ -1,10 +1,7 @@ -#if !defined(BOB_H) -#define BOB_H +#pragma once namespace bob { // TODO: add your solution here } // namespace bob - -#endif // BOB_H \ No newline at end of file diff --git a/exercises/practice/circular-buffer/.meta/example.h b/exercises/practice/circular-buffer/.meta/example.h index acb29887b..a2a6a74a2 100644 --- a/exercises/practice/circular-buffer/.meta/example.h +++ b/exercises/practice/circular-buffer/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(CIRCULAR_BUFFER_H_) -#define CIRCULAR_BUFFER_H_ +#pragma once #include #include @@ -56,5 +55,3 @@ void circular_buffer::push_back(ValueType item) { } } // namespace circular_buffer - -#endif // !CIRCULAR_BUFFER_H_ \ No newline at end of file diff --git a/exercises/practice/circular-buffer/circular_buffer.h b/exercises/practice/circular-buffer/circular_buffer.h index 3af7dc602..a536582fb 100644 --- a/exercises/practice/circular-buffer/circular_buffer.h +++ b/exercises/practice/circular-buffer/circular_buffer.h @@ -1,10 +1,7 @@ -#if !defined(CIRCULAR_BUFFER_H) -#define CIRCULAR_BUFFER_H +#pragma once namespace circular_buffer { // TODO: add your solution here } // namespace circular_buffer - -#endif // CIRCULAR_BUFFER_H \ No newline at end of file diff --git a/exercises/practice/clock/.meta/example.h b/exercises/practice/clock/.meta/example.h index 0396c9638..4267e950a 100644 --- a/exercises/practice/clock/.meta/example.h +++ b/exercises/practice/clock/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(CLOCK_H) -#define CLOCK_H +#pragma once #include @@ -28,5 +27,3 @@ inline bool operator!=(const clock& lhs, const clock& rhs) { } } // namespace date_independent - -#endif diff --git a/exercises/practice/clock/clock.h b/exercises/practice/clock/clock.h index 4f3e76985..94326f3d5 100644 --- a/exercises/practice/clock/clock.h +++ b/exercises/practice/clock/clock.h @@ -1,10 +1,7 @@ -#if !defined(CLOCK_H) -#define CLOCK_H +#pragma once namespace date_independent { // TODO: add your solution here } // namespace date_independent - -#endif // CLOCK_H \ No newline at end of file diff --git a/exercises/practice/collatz-conjecture/.meta/example.h b/exercises/practice/collatz-conjecture/.meta/example.h index abbcd5912..48e169297 100644 --- a/exercises/practice/collatz-conjecture/.meta/example.h +++ b/exercises/practice/collatz-conjecture/.meta/example.h @@ -1,10 +1,7 @@ -#if !defined(COLLATZ_CONJECTURE_H_) -#define COLLATZ_CONJECTURE_H_ +#pragma once namespace collatz_conjecture { int steps(int value); } // namespace collatz_conjecture - -#endif // !COLLATZ_CONJECTURE_H_ \ No newline at end of file diff --git a/exercises/practice/collatz-conjecture/collatz_conjecture.h b/exercises/practice/collatz-conjecture/collatz_conjecture.h index 3da7e2e37..50fa4c294 100644 --- a/exercises/practice/collatz-conjecture/collatz_conjecture.h +++ b/exercises/practice/collatz-conjecture/collatz_conjecture.h @@ -1,10 +1,7 @@ -#if !defined(COLLATZ_CONJECTURE_H) -#define COLLATZ_CONJECTURE_H +#pragma once namespace collatz_conjecture { // TODO: add your solution here } // namespace collatz_conjecture - -#endif // COLLATZ_CONJECTURE_H \ No newline at end of file diff --git a/exercises/practice/complex-numbers/.meta/example.h b/exercises/practice/complex-numbers/.meta/example.h index 49a5ad008..01fa7382e 100644 --- a/exercises/practice/complex-numbers/.meta/example.h +++ b/exercises/practice/complex-numbers/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(COMPLEX_NUMBERS_H) -#define COMPLEX_NUMBERS_H +#pragma once #include namespace complex_numbers { @@ -34,5 +33,3 @@ Complex operator/(const Complex& complex, double scalar); Complex operator/(double scalar, const Complex& complex); } // namespace complex_numbers - -#endif diff --git a/exercises/practice/complex-numbers/complex_numbers.h b/exercises/practice/complex-numbers/complex_numbers.h index 496dacc48..df0ec3531 100644 --- a/exercises/practice/complex-numbers/complex_numbers.h +++ b/exercises/practice/complex-numbers/complex_numbers.h @@ -1,10 +1,7 @@ -#if !defined(COMPLEX_NUMBERS_H) -#define COMPLEX_NUMBERS_H +#pragma once namespace complex_numbers { // TODO: add your solution here } // namespace complex_numbers - -#endif // COMPLEX_NUMBERS_H diff --git a/exercises/practice/crypto-square/.meta/example.h b/exercises/practice/crypto-square/.meta/example.h index 3ac12dc0d..4576e263e 100644 --- a/exercises/practice/crypto-square/.meta/example.h +++ b/exercises/practice/crypto-square/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(CRYPTO_SQUARE_H) -#define CRYPTO_SQUARE_H +#pragma once #include #include @@ -25,5 +24,3 @@ class cipher { }; } // namespace crypto_square - -#endif diff --git a/exercises/practice/crypto-square/crypto_square.h b/exercises/practice/crypto-square/crypto_square.h index aa9d90f44..4227cc33c 100644 --- a/exercises/practice/crypto-square/crypto_square.h +++ b/exercises/practice/crypto-square/crypto_square.h @@ -1,10 +1,7 @@ -#if !defined(CRYPTO_SQUARE_H) -#define CRYPTO_SQUARE_H +#pragma once namespace crypto_square { // TODO: add your solution here } // namespace crypto_square - -#endif // CRYPTO_SQUARE_H \ No newline at end of file diff --git a/exercises/practice/darts/.meta/example.h b/exercises/practice/darts/.meta/example.h index cf3fb376c..527fbd052 100644 --- a/exercises/practice/darts/.meta/example.h +++ b/exercises/practice/darts/.meta/example.h @@ -1,10 +1,7 @@ -#if !defined(DARTS_H) -#define DARTS_H +#pragma once namespace darts { int score(float x, float y); } // namespace darts - -#endif // DARTS_H \ No newline at end of file diff --git a/exercises/practice/darts/darts.h b/exercises/practice/darts/darts.h index 23d08aa26..b78e0df08 100644 --- a/exercises/practice/darts/darts.h +++ b/exercises/practice/darts/darts.h @@ -1,10 +1,7 @@ -#if !defined(DARTS_H) -#define DARTS_H +#pragma once namespace darts { // TODO: add your solution here } // namespace darts - -#endif // DARTS_H \ No newline at end of file diff --git a/exercises/practice/difference-of-squares/.meta/example.h b/exercises/practice/difference-of-squares/.meta/example.h index dff8d4aeb..f84e12dc7 100644 --- a/exercises/practice/difference-of-squares/.meta/example.h +++ b/exercises/practice/difference-of-squares/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(DIFFERENCE_OF_SQUARES_H) -#define DIFFERENCE_OF_SQUARES_H +#pragma once namespace difference_of_squares { @@ -8,5 +7,3 @@ int sum_of_squares(int n); int difference(int n); } // namespace difference_of_squares - -#endif diff --git a/exercises/practice/difference-of-squares/difference_of_squares.h b/exercises/practice/difference-of-squares/difference_of_squares.h index 409f1e1f3..3dcd30e6a 100644 --- a/exercises/practice/difference-of-squares/difference_of_squares.h +++ b/exercises/practice/difference-of-squares/difference_of_squares.h @@ -1,10 +1,7 @@ -#if !defined(DIFFERENCE_OF_SQUARES_H) -#define DIFFERENCE_OF_SQUARES_H +#pragma once namespace difference_of_squares { // TODO: add your solution here } // namespace difference_of_squares - -#endif // DIFFERENCE_OF_SQUARES_H \ No newline at end of file diff --git a/exercises/practice/etl/.meta/example.h b/exercises/practice/etl/.meta/example.h index 33541b069..382bfb29e 100644 --- a/exercises/practice/etl/.meta/example.h +++ b/exercises/practice/etl/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(ETL_H) -#define ETL_H +#pragma once #include #include @@ -9,5 +8,3 @@ namespace etl { std::map transform(std::map> const& old); } - -#endif diff --git a/exercises/practice/etl/etl.h b/exercises/practice/etl/etl.h index 618fc6df9..881530cf9 100644 --- a/exercises/practice/etl/etl.h +++ b/exercises/practice/etl/etl.h @@ -1,10 +1,7 @@ -#if !defined(ETL_H) -#define ETL_H +#pragma once namespace etl { // TODO: add your solution here } // namespace etl - -#endif // ETL_H \ No newline at end of file diff --git a/exercises/practice/food-chain/.meta/example.h b/exercises/practice/food-chain/.meta/example.h index 058d5ffcb..a53800a3f 100644 --- a/exercises/practice/food-chain/.meta/example.h +++ b/exercises/practice/food-chain/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(FOOD_CHAIN_H) -#define FOOD_CHAIN_H +#pragma once #include @@ -10,5 +9,3 @@ std::string verses(unsigned begin, unsigned end); std::string sing(); } // namespace food_chain - -#endif diff --git a/exercises/practice/food-chain/food_chain.h b/exercises/practice/food-chain/food_chain.h index a1184f896..89605aeeb 100644 --- a/exercises/practice/food-chain/food_chain.h +++ b/exercises/practice/food-chain/food_chain.h @@ -1,10 +1,7 @@ -#if !defined(FOOD_CHAIN_H) -#define FOOD_CHAIN_H +#pragma once namespace food_chain { // TODO: add your solution here } // namespace food_chain - -#endif // FOOD_CHAIN_H \ No newline at end of file diff --git a/exercises/practice/gigasecond/.meta/example.h b/exercises/practice/gigasecond/.meta/example.h index f7f07ba9a..c6cf5ee9f 100644 --- a/exercises/practice/gigasecond/.meta/example.h +++ b/exercises/practice/gigasecond/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(GIGASECOND_H) -#define GIGASECOND_H +#pragma once #include @@ -8,5 +7,3 @@ namespace gigasecond { boost::posix_time::ptime advance(const boost::posix_time::ptime& start); } - -#endif diff --git a/exercises/practice/gigasecond/gigasecond.h b/exercises/practice/gigasecond/gigasecond.h index 90a5cfb8a..a3bd660e6 100644 --- a/exercises/practice/gigasecond/gigasecond.h +++ b/exercises/practice/gigasecond/gigasecond.h @@ -1,10 +1,7 @@ -#if !defined(GIGASECOND_H) -#define GIGASECOND_H +#pragma once namespace gigasecond { // TODO: add your solution here } // namespace gigasecond - -#endif // GIGASECOND_H \ No newline at end of file diff --git a/exercises/practice/grade-school/.meta/example.h b/exercises/practice/grade-school/.meta/example.h index 82377e437..affad18d3 100644 --- a/exercises/practice/grade-school/.meta/example.h +++ b/exercises/practice/grade-school/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(GRADE_SCHOOL_H) -#define GRADE_SCHOOL_H +#pragma once #include #include @@ -22,5 +21,3 @@ class school { }; } // namespace grade_school - -#endif diff --git a/exercises/practice/grade-school/grade_school.h b/exercises/practice/grade-school/grade_school.h index 514f222c6..2924a32f7 100644 --- a/exercises/practice/grade-school/grade_school.h +++ b/exercises/practice/grade-school/grade_school.h @@ -1,10 +1,7 @@ -#if !defined(GRADE_SCHOOL_H) -#define GRADE_SCHOOL_H +#pragma once namespace grade_school { // TODO: add your solution here } // namespace grade_school - -#endif // GRADE_SCHOOL_H \ No newline at end of file diff --git a/exercises/practice/grains/.meta/example.h b/exercises/practice/grains/.meta/example.h index 46133528d..4ea880f8b 100644 --- a/exercises/practice/grains/.meta/example.h +++ b/exercises/practice/grains/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(GRAINS_H) -#define GRAINS_H +#pragma once namespace grains { @@ -8,5 +7,3 @@ unsigned long long square(int which); unsigned long long total(); } // namespace grains - -#endif diff --git a/exercises/practice/grains/grains.h b/exercises/practice/grains/grains.h index aa00278c3..1d9173b7e 100644 --- a/exercises/practice/grains/grains.h +++ b/exercises/practice/grains/grains.h @@ -1,10 +1,7 @@ -#if !defined(GRAINS_H) -#define GRAINS_H +#pragma once namespace grains { // TODO: add your solution here } // namespace grains - -#endif // GRAINS_H \ No newline at end of file diff --git a/exercises/practice/hamming/.meta/example.h b/exercises/practice/hamming/.meta/example.h index cecef603b..f369ca9f3 100644 --- a/exercises/practice/hamming/.meta/example.h +++ b/exercises/practice/hamming/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(HAMMING_H) -#define HAMMING_H +#pragma once #include @@ -8,5 +7,3 @@ namespace hamming { int compute(std::string const& lhs, std::string const& rhs); } - -#endif diff --git a/exercises/practice/hamming/hamming.h b/exercises/practice/hamming/hamming.h index 5a2f1979c..eacebeb22 100644 --- a/exercises/practice/hamming/hamming.h +++ b/exercises/practice/hamming/hamming.h @@ -1,10 +1,7 @@ -#if !defined(HAMMING_H) -#define HAMMING_H +#pragma once namespace hamming { // TODO: add your solution here } // namespace hamming - -#endif // HAMMING_H \ No newline at end of file diff --git a/exercises/practice/hexadecimal/.meta/example.h b/exercises/practice/hexadecimal/.meta/example.h index ea5151be2..ed0e6a355 100644 --- a/exercises/practice/hexadecimal/.meta/example.h +++ b/exercises/practice/hexadecimal/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(HEXADECIMAL_H) -#define HEXADECIMAL_H +#pragma once #include @@ -8,5 +7,3 @@ namespace hexadecimal { int convert(const std::string &text); } - -#endif diff --git a/exercises/practice/hexadecimal/hexadecimal.h b/exercises/practice/hexadecimal/hexadecimal.h index c3a648ea4..cbcdff6ec 100644 --- a/exercises/practice/hexadecimal/hexadecimal.h +++ b/exercises/practice/hexadecimal/hexadecimal.h @@ -1,10 +1,7 @@ -#if !defined(HEXADECIMAL_H) -#define HEXADECIMAL_H +#pragma once namespace hexadecimal { // TODO: add your solution here } // namespace hexadecimal - -#endif // HEXADECIMAL_H \ No newline at end of file diff --git a/exercises/practice/isbn-verifier/.meta/example.h b/exercises/practice/isbn-verifier/.meta/example.h index c8a961213..460eba0e3 100644 --- a/exercises/practice/isbn-verifier/.meta/example.h +++ b/exercises/practice/isbn-verifier/.meta/example.h @@ -1,10 +1,7 @@ -#if !defined(ISBN_VERIFIER_H) -#define ISBN_VERIFIER_H +#pragma once #include namespace isbn_verifier { bool is_valid(const std::string& isbn); } // namespace isbn_verifier - -#endif // ISBN_VERIFIER_H \ No newline at end of file diff --git a/exercises/practice/isbn-verifier/isbn_verifier.h b/exercises/practice/isbn-verifier/isbn_verifier.h index 8c46e5d43..3102c1624 100644 --- a/exercises/practice/isbn-verifier/isbn_verifier.h +++ b/exercises/practice/isbn-verifier/isbn_verifier.h @@ -1,10 +1,7 @@ -#if !defined(ISBN_VERIFIER_H) -#define ISBN_VERIFIER_H +#pragma once namespace isbn_verifier { // TODO: add your solution here } // namespace isbn_verifier - -#endif // ISBN_VERIFIER_H \ No newline at end of file diff --git a/exercises/practice/isogram/.meta/example.h b/exercises/practice/isogram/.meta/example.h index fe8227850..7ffaad28c 100644 --- a/exercises/practice/isogram/.meta/example.h +++ b/exercises/practice/isogram/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(ISOGRAM_H) -#define ISOGRAM_H +#pragma once #include @@ -8,4 +7,3 @@ namespace isogram { bool is_isogram(std::string const&); } -#endif // ISOGRAM_H diff --git a/exercises/practice/isogram/isogram.h b/exercises/practice/isogram/isogram.h index ab2d5da47..998f15dac 100644 --- a/exercises/practice/isogram/isogram.h +++ b/exercises/practice/isogram/isogram.h @@ -1,10 +1,7 @@ -#if !defined(ISOGRAM_H) -#define ISOGRAM_H +#pragma once namespace isogram { // TODO: add your solution here } // namespace isogram - -#endif // ISOGRAM_H \ No newline at end of file diff --git a/exercises/practice/knapsack/.meta/example.h b/exercises/practice/knapsack/.meta/example.h index 20a5f99c7..141732055 100644 --- a/exercises/practice/knapsack/.meta/example.h +++ b/exercises/practice/knapsack/.meta/example.h @@ -1,5 +1,4 @@ -#ifndef KNAPSACK_H -#define KNAPSACK_H +#pragma once #include @@ -13,5 +12,3 @@ struct Item { int maximum_value(int maximum_weight, const std::vector& items); } // namespace knapsack - -#endif // KNAPSACK_H diff --git a/exercises/practice/knapsack/knapsack.h b/exercises/practice/knapsack/knapsack.h index c731efa9a..2917f8a70 100644 --- a/exercises/practice/knapsack/knapsack.h +++ b/exercises/practice/knapsack/knapsack.h @@ -1,5 +1,4 @@ -#ifndef KNAPSACK_H -#define KNAPSACK_H +#pragma once namespace knapsack { @@ -9,5 +8,3 @@ struct Item { }; } // namespace knapsack - -#endif // KNAPSACK_H diff --git a/exercises/practice/largest-series-product/.meta/example.h b/exercises/practice/largest-series-product/.meta/example.h index 932d7ac40..d6d2f87dd 100644 --- a/exercises/practice/largest-series-product/.meta/example.h +++ b/exercises/practice/largest-series-product/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(LARGEST_SERIES_PRODUCT_H) -#define LARGEST_SERIES_PRODUCT_H +#pragma once #include @@ -8,5 +7,3 @@ namespace largest_series_product { int largest_product(const std::string& digits, int span); } // namespace largest_series_product - -#endif // LARGEST_SERIES_PRODUCT_H diff --git a/exercises/practice/largest-series-product/largest_series_product.h b/exercises/practice/largest-series-product/largest_series_product.h index 51fac9611..4244d9a86 100644 --- a/exercises/practice/largest-series-product/largest_series_product.h +++ b/exercises/practice/largest-series-product/largest_series_product.h @@ -1,10 +1,7 @@ -#if !defined(LARGEST_SERIES_PRODUCT_H) -#define LARGEST_SERIES_PRODUCT_H +#pragma once namespace largest_series_product { // TODO: add your solution here } // namespace largest_series_product - -#endif // LARGEST_SERIES_PRODUCT_H \ No newline at end of file diff --git a/exercises/practice/leap/.meta/example.h b/exercises/practice/leap/.meta/example.h index 3d4bd23af..50195cdf2 100644 --- a/exercises/practice/leap/.meta/example.h +++ b/exercises/practice/leap/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(LEAP_H) -#define LEAP_H +#pragma once namespace leap { @@ -8,5 +7,3 @@ inline bool is_leap_year(int year) { } } // namespace leap - -#endif diff --git a/exercises/practice/leap/leap.h b/exercises/practice/leap/leap.h index ceaf3df9e..0696a1d93 100644 --- a/exercises/practice/leap/leap.h +++ b/exercises/practice/leap/leap.h @@ -1,10 +1,7 @@ -#if !defined(LEAP_H) -#define LEAP_H +#pragma once namespace leap { // TODO: add your solution here } // namespace leap - -#endif // LEAP_H \ No newline at end of file diff --git a/exercises/practice/luhn/.meta/example.h b/exercises/practice/luhn/.meta/example.h index 39cecce57..f9004c6cf 100644 --- a/exercises/practice/luhn/.meta/example.h +++ b/exercises/practice/luhn/.meta/example.h @@ -1,10 +1,7 @@ -#if !defined(LUHN_H) -#define LUHN_H +#pragma once #include namespace luhn { bool valid(std::string const&); } - -#endif // LUHN_H \ No newline at end of file diff --git a/exercises/practice/luhn/luhn.h b/exercises/practice/luhn/luhn.h index 8db288dd8..e1698ddd3 100644 --- a/exercises/practice/luhn/luhn.h +++ b/exercises/practice/luhn/luhn.h @@ -1,10 +1,7 @@ -#if !defined(LUHN_H) -#define LUHN_H +#pragma once namespace luhn { // TODO: add your solution here } // namespace luhn - -#endif // LUHN_H \ No newline at end of file diff --git a/exercises/practice/matching-brackets/.meta/example.h b/exercises/practice/matching-brackets/.meta/example.h index ad037c703..607a8f35f 100644 --- a/exercises/practice/matching-brackets/.meta/example.h +++ b/exercises/practice/matching-brackets/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(MATCHING_BRACKETS_H) -#define MATCHING_BRACKETS_H +#pragma once #include @@ -8,5 +7,3 @@ namespace matching_brackets { bool check(std::string const& expression); } - -#endif diff --git a/exercises/practice/matching-brackets/matching_brackets.h b/exercises/practice/matching-brackets/matching_brackets.h index b66179f4c..79e2db8a9 100644 --- a/exercises/practice/matching-brackets/matching_brackets.h +++ b/exercises/practice/matching-brackets/matching_brackets.h @@ -1,10 +1,7 @@ -#if !defined(MATCHING_BRACKETS_H) -#define MATCHING_BRACKETS_H +#pragma once namespace matching_brackets { // TODO: add your solution here } // namespace matching_brackets - -#endif // MATCHING_BRACKETS_H \ No newline at end of file diff --git a/exercises/practice/meetup/.meta/example.h b/exercises/practice/meetup/.meta/example.h index 99ab8c603..c31b14972 100644 --- a/exercises/practice/meetup/.meta/example.h +++ b/exercises/practice/meetup/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(MEETUP_H) -#define MEETUP_H +#pragma once #include @@ -188,5 +187,3 @@ class scheduler { }; } // namespace meetup - -#endif diff --git a/exercises/practice/meetup/meetup.h b/exercises/practice/meetup/meetup.h index 3d14e6924..28be263c1 100644 --- a/exercises/practice/meetup/meetup.h +++ b/exercises/practice/meetup/meetup.h @@ -1,10 +1,7 @@ -#if !defined(MEETUP_H) -#define MEETUP_H +#pragma once namespace meetup { // TODO: add your solution here } // namespace meetup - -#endif // MEETUP_H \ No newline at end of file diff --git a/exercises/practice/nth-prime/.meta/example.h b/exercises/practice/nth-prime/.meta/example.h index 98cf20f99..525ef67ef 100644 --- a/exercises/practice/nth-prime/.meta/example.h +++ b/exercises/practice/nth-prime/.meta/example.h @@ -1,8 +1,5 @@ -#if !defined(NTH_PRIME_H) -#define NTH_PRIME_H +#pragma once namespace nth_prime { int nth(int n); } - -#endif diff --git a/exercises/practice/nth-prime/nth_prime.h b/exercises/practice/nth-prime/nth_prime.h index c5e97957a..08d3acf2a 100644 --- a/exercises/practice/nth-prime/nth_prime.h +++ b/exercises/practice/nth-prime/nth_prime.h @@ -1,10 +1,7 @@ -#if !defined(NTH_PRIME_H) -#define NTH_PRIME_H +#pragma once namespace nth_prime { // TODO: add your solution here } // namespace nth_prime - -#endif // NTH_PRIME_H \ No newline at end of file diff --git a/exercises/practice/nucleotide-count/.meta/example.h b/exercises/practice/nucleotide-count/.meta/example.h index f40f94076..cf676515c 100644 --- a/exercises/practice/nucleotide-count/.meta/example.h +++ b/exercises/practice/nucleotide-count/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(NUCLEOTIDE_COUNT_H) -#define NUCLEOTIDE_COUNT_H +#pragma once #include #include @@ -9,5 +8,3 @@ namespace nucleotide_count { std::map count(std::string_view dna); } - -#endif diff --git a/exercises/practice/nucleotide-count/nucleotide_count.h b/exercises/practice/nucleotide-count/nucleotide_count.h index 599fcb90e..27001b2f3 100644 --- a/exercises/practice/nucleotide-count/nucleotide_count.h +++ b/exercises/practice/nucleotide-count/nucleotide_count.h @@ -1,10 +1,7 @@ -#if !defined(NUCLEOTIDE_COUNT_H) -#define NUCLEOTIDE_COUNT_H +#pragma once namespace nucleotide_count { // TODO: add your solution here } // namespace nucleotide_count - -#endif // NUCLEOTIDE_COUNT_H \ No newline at end of file diff --git a/exercises/practice/pangram/.approaches/algorithm-allof/content.md b/exercises/practice/pangram/.approaches/algorithm-allof/content.md index 757d2e3b3..8747619f8 100644 --- a/exercises/practice/pangram/.approaches/algorithm-allof/content.md +++ b/exercises/practice/pangram/.approaches/algorithm-allof/content.md @@ -2,15 +2,12 @@ **pangram.h** ```cpp -#if !defined(PANGRAM_H) -#define PANGRAM_H +#pragma once #include namespace pangram { bool is_pangram(std::string_view phrase); } // namespace pangram - -#endif // PANGRAM_H ``` **pangram.cpp** diff --git a/exercises/practice/pangram/.approaches/bitset-all/content.md b/exercises/practice/pangram/.approaches/bitset-all/content.md index f7ecb6efb..1fdf2070c 100644 --- a/exercises/practice/pangram/.approaches/bitset-all/content.md +++ b/exercises/practice/pangram/.approaches/bitset-all/content.md @@ -3,15 +3,12 @@ **pangram.h** ```cpp -#if !defined(PANGRAM_H) -#define PANGRAM_H +#pragma once #include namespace pangram { bool is_pangram(std::string_view phrase); } // namespace pangram - -#endif // PANGRAM_H ``` **pangram.cpp** diff --git a/exercises/practice/pangram/.approaches/introduction.md b/exercises/practice/pangram/.approaches/introduction.md index 64d846aa4..55fbd76dc 100644 --- a/exercises/practice/pangram/.approaches/introduction.md +++ b/exercises/practice/pangram/.approaches/introduction.md @@ -9,15 +9,12 @@ Another approach can use the [`algorithm.all_of()`][all_of] function. **pangram.h** ```cpp -#if !defined(PANGRAM_H) -#define PANGRAM_H +#pragma once #include namespace pangram { bool is_pangram(std::string_view phrase); } // namespace pangram - -#endif // PANGRAM_H ``` **pangram.cpp** diff --git a/exercises/practice/pangram/.meta/example.h b/exercises/practice/pangram/.meta/example.h index f3908f0c7..9c933b497 100644 --- a/exercises/practice/pangram/.meta/example.h +++ b/exercises/practice/pangram/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(PANGRAM_H) -#define PANGRAM_H +#pragma once #include namespace pangram { @@ -7,4 +6,3 @@ namespace pangram { bool is_pangram(const std::string &s); } -#endif diff --git a/exercises/practice/pangram/pangram.h b/exercises/practice/pangram/pangram.h index 849e0995c..ff1ebf723 100644 --- a/exercises/practice/pangram/pangram.h +++ b/exercises/practice/pangram/pangram.h @@ -1,10 +1,7 @@ -#if !defined(PANGRAM_H) -#define PANGRAM_H +#pragma once namespace pangram { // TODO: add your solution here } // namespace pangram - -#endif // PANGRAM_H \ No newline at end of file diff --git a/exercises/practice/parallel-letter-frequency/.meta/example.h b/exercises/practice/parallel-letter-frequency/.meta/example.h index 284620bcd..922c6d6c4 100644 --- a/exercises/practice/parallel-letter-frequency/.meta/example.h +++ b/exercises/practice/parallel-letter-frequency/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(PARALLEL_LETTER_FREQUENCY_H) -#define PARALLEL_LETTER_FREQUENCY_H +#pragma once #include #include @@ -11,5 +10,3 @@ namespace parallel_letter_frequency { std::vector const& texts); } - -#endif diff --git a/exercises/practice/parallel-letter-frequency/parallel_letter_frequency.h b/exercises/practice/parallel-letter-frequency/parallel_letter_frequency.h index 2cd676294..c4b504b23 100644 --- a/exercises/practice/parallel-letter-frequency/parallel_letter_frequency.h +++ b/exercises/practice/parallel-letter-frequency/parallel_letter_frequency.h @@ -1,6 +1,3 @@ -#if !defined(PARALLEL_LETTER_FREQUENCY_H) -#define PARALLEL_LETTER_FREQUENCY_H +#pragma once namespace parallel_letter_frequency {} - -#endif diff --git a/exercises/practice/pascals-triangle/.meta/example.h b/exercises/practice/pascals-triangle/.meta/example.h index a2a60201b..fea714f77 100644 --- a/exercises/practice/pascals-triangle/.meta/example.h +++ b/exercises/practice/pascals-triangle/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(PASCALS_TRIANGLE_H) -#define PASCALS_TRIANGLE_H +#pragma once #include #include @@ -11,5 +10,3 @@ using std::size_t; std::vector> generate_rows(size_t n); } // namespace pascals_triangle - -#endif diff --git a/exercises/practice/pascals-triangle/pascals_triangle.h b/exercises/practice/pascals-triangle/pascals_triangle.h index 993644809..d1053509a 100644 --- a/exercises/practice/pascals-triangle/pascals_triangle.h +++ b/exercises/practice/pascals-triangle/pascals_triangle.h @@ -1,10 +1,7 @@ -#if !defined(PASCALS_TRIANGLE_H) -#define PASCALS_TRIANGLE_H +#pragma once namespace pascals_triangle { // TODO: add your solution here } // namespace pascals_triangle - -#endif // PASCALS_TRIANGLE_H \ No newline at end of file diff --git a/exercises/practice/perfect-numbers/.meta/example.h b/exercises/practice/perfect-numbers/.meta/example.h index 6eee3e119..61c782ae8 100644 --- a/exercises/practice/perfect-numbers/.meta/example.h +++ b/exercises/practice/perfect-numbers/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(PERFECT_NUMBERS_H) -#define PERFECT_NUMBERS_H +#pragma once namespace perfect_numbers { enum class classification { deficient, perfect, abundant }; @@ -7,5 +6,3 @@ enum class classification { deficient, perfect, abundant }; classification classify(int n); } // namespace perfect_numbers - -#endif diff --git a/exercises/practice/perfect-numbers/perfect_numbers.h b/exercises/practice/perfect-numbers/perfect_numbers.h index e97d0275c..3ddb1bacf 100644 --- a/exercises/practice/perfect-numbers/perfect_numbers.h +++ b/exercises/practice/perfect-numbers/perfect_numbers.h @@ -1,6 +1,3 @@ -#if !defined(PERFECT_NUMBERS_H) -#define PERFECT_NUMBERS_H +#pragma once namespace perfect_numbers {} // namespace perfect_numbers - -#endif // PERFECT_NUMBERS_H \ No newline at end of file diff --git a/exercises/practice/phone-number/.meta/example.h b/exercises/practice/phone-number/.meta/example.h index 8e04fc950..4a652973f 100644 --- a/exercises/practice/phone-number/.meta/example.h +++ b/exercises/practice/phone-number/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(PHONE_NUMBER_H) -#define PHONE_NUMBER_H +#pragma once #include @@ -23,5 +22,3 @@ class phone_number { }; } // namespace phone_number - -#endif diff --git a/exercises/practice/phone-number/phone_number.h b/exercises/practice/phone-number/phone_number.h index 77f5d759d..2809c5f61 100644 --- a/exercises/practice/phone-number/phone_number.h +++ b/exercises/practice/phone-number/phone_number.h @@ -1,10 +1,7 @@ -#if !defined(PHONE_NUMBER_H) -#define PHONE_NUMBER_H +#pragma once namespace phone_number { // TODO: add your solution here } // namespace phone_number - -#endif // PHONE_NUMBER_H \ No newline at end of file diff --git a/exercises/practice/prime-factors/.meta/example.h b/exercises/practice/prime-factors/.meta/example.h index f1971f1b3..b20226c01 100644 --- a/exercises/practice/prime-factors/.meta/example.h +++ b/exercises/practice/prime-factors/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(PRIME_FACTORS_H) -#define PRIME_FACTORS_H +#pragma once #include @@ -8,5 +7,3 @@ namespace prime_factors { std::vector of(long long n); } - -#endif diff --git a/exercises/practice/prime-factors/prime_factors.h b/exercises/practice/prime-factors/prime_factors.h index 141327fdd..5094930dc 100644 --- a/exercises/practice/prime-factors/prime_factors.h +++ b/exercises/practice/prime-factors/prime_factors.h @@ -1,10 +1,7 @@ -#if !defined(PRIME_FACTORS_H) -#define PRIME_FACTORS_H +#pragma once namespace prime_factors { // TODO: add your solution here } // namespace prime_factors - -#endif // PRIME_FACTORS_H \ No newline at end of file diff --git a/exercises/practice/protein-translation/.meta/example.h b/exercises/practice/protein-translation/.meta/example.h index 2de3d75d6..491816c25 100644 --- a/exercises/practice/protein-translation/.meta/example.h +++ b/exercises/practice/protein-translation/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(PROTEIN_TRANSLATION_H_) -#define PROTEIN_TRANSLATION_H_ +#pragma once #include #include @@ -9,5 +8,3 @@ namespace protein_translation { std::vector proteins(std::string rna); } // namespace protein_translation - -#endif // !PROTEIN_TRANSLATION_H_ diff --git a/exercises/practice/protein-translation/protein_translation.h b/exercises/practice/protein-translation/protein_translation.h index b8812ce3f..f919b5222 100644 --- a/exercises/practice/protein-translation/protein_translation.h +++ b/exercises/practice/protein-translation/protein_translation.h @@ -1,10 +1,7 @@ -#if !defined(PROTEIN_TRANSLATION_H) -#define PROTEIN_TRANSLATION_H +#pragma once namespace protein_translation { // TODO: add your solution here } // namespace protein_translation - -#endif // PROTEIN_TRANSLATION_H diff --git a/exercises/practice/queen-attack/.meta/example.h b/exercises/practice/queen-attack/.meta/example.h index 9057bc6b0..91e5602ad 100644 --- a/exercises/practice/queen-attack/.meta/example.h +++ b/exercises/practice/queen-attack/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(QUEEN_ATTACK_H) -#define QUEEN_ATTACK_H +#pragma once #include #include @@ -26,5 +25,3 @@ class chess_board { }; } // namespace queen_attack - -#endif diff --git a/exercises/practice/queen-attack/queen_attack.h b/exercises/practice/queen-attack/queen_attack.h index 9be3ff124..245e535fc 100644 --- a/exercises/practice/queen-attack/queen_attack.h +++ b/exercises/practice/queen-attack/queen_attack.h @@ -1,10 +1,7 @@ -#if !defined(QUEEN_ATTACK_H) -#define QUEEN_ATTACK_H +#pragma once namespace queen_attack { // TODO: add your solution here } // namespace queen_attack - -#endif // QUEEN_ATTACK_H \ No newline at end of file diff --git a/exercises/practice/raindrops/.meta/example.h b/exercises/practice/raindrops/.meta/example.h index 57495477b..5bbe6c661 100644 --- a/exercises/practice/raindrops/.meta/example.h +++ b/exercises/practice/raindrops/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(RAINDROPS_H) -#define RAINDROPS_H +#pragma once #include @@ -8,5 +7,3 @@ namespace raindrops { std::string convert(int drops); } - -#endif diff --git a/exercises/practice/raindrops/raindrops.h b/exercises/practice/raindrops/raindrops.h index 9021736d3..09004f683 100644 --- a/exercises/practice/raindrops/raindrops.h +++ b/exercises/practice/raindrops/raindrops.h @@ -1,10 +1,7 @@ -#if !defined(RAINDROPS_H) -#define RAINDROPS_H +#pragma once namespace raindrops { // TODO: add your solution here } // namespace raindrops - -#endif // RAINDROPS_H \ No newline at end of file diff --git a/exercises/practice/reverse-string/.approaches/direct-construction/content.md b/exercises/practice/reverse-string/.approaches/direct-construction/content.md index 17a63d1e8..1c930fed7 100644 --- a/exercises/practice/reverse-string/.approaches/direct-construction/content.md +++ b/exercises/practice/reverse-string/.approaches/direct-construction/content.md @@ -2,8 +2,7 @@ **reverse_string.h** ```cpp -#ifndef REVERSE_STRING_H -#define REVERSE_STRING_H +#pragma once #include @@ -11,8 +10,6 @@ namespace reverse_string { std::string reverse_string(std::string_view str); } - -#endif // REVERSE_STRING_H ``` **reverse_string.cpp** diff --git a/exercises/practice/reverse-string/.approaches/divide-and-conquer/content.md b/exercises/practice/reverse-string/.approaches/divide-and-conquer/content.md index ea41ea913..7c3edbe93 100644 --- a/exercises/practice/reverse-string/.approaches/divide-and-conquer/content.md +++ b/exercises/practice/reverse-string/.approaches/divide-and-conquer/content.md @@ -2,8 +2,7 @@ **reverse_string.h** ```cpp -#ifndef REVERSE_STRING_H -#define REVERSE_STRING_H +#pragma once #include @@ -11,8 +10,6 @@ namespace reverse_string { std::string reverse_string(std::string_view str); } - -#endif // REVERSE_STRING_H ``` **reverse_string.cpp** diff --git a/exercises/practice/reverse-string/.approaches/iterative/content.md b/exercises/practice/reverse-string/.approaches/iterative/content.md index d1e12b8c0..b5e2c45d7 100644 --- a/exercises/practice/reverse-string/.approaches/iterative/content.md +++ b/exercises/practice/reverse-string/.approaches/iterative/content.md @@ -2,8 +2,7 @@ **reverse_string.h** ```cpp -#ifndef REVERSE_STRING_H -#define REVERSE_STRING_H +#pragma once #include @@ -11,8 +10,6 @@ namespace reverse_string { std::string reverse_string(const std::string& str); } - -#endif // REVERSE_STRING_H ``` **reverse_string.cpp** diff --git a/exercises/practice/reverse-string/.approaches/linear-recursion/content.md b/exercises/practice/reverse-string/.approaches/linear-recursion/content.md index 6de6cd6da..1d733111c 100644 --- a/exercises/practice/reverse-string/.approaches/linear-recursion/content.md +++ b/exercises/practice/reverse-string/.approaches/linear-recursion/content.md @@ -2,8 +2,7 @@ **reverse_string.h** ```cpp -#ifndef REVERSE_STRING_H -#define REVERSE_STRING_H +#pragma once #include @@ -11,8 +10,6 @@ namespace reverse_string { std::string reverse_string(std::string_view str); } - -#endif // REVERSE_STRING_H ``` **reverse_string.cpp** diff --git a/exercises/practice/reverse-string/.approaches/over-engineered/content.md b/exercises/practice/reverse-string/.approaches/over-engineered/content.md index 08b5b0477..3ac5490d3 100644 --- a/exercises/practice/reverse-string/.approaches/over-engineered/content.md +++ b/exercises/practice/reverse-string/.approaches/over-engineered/content.md @@ -2,8 +2,7 @@ **reverse_string.h** ```cpp -#ifndef REVERSE_STRING_H -#define REVERSE_STRING_H +#pragma once #include @@ -15,8 +14,6 @@ namespace reverse_string [[nodiscard]] std::string reverse_string(std::string_view str); [[nodiscard]] std::string reverse_string(const char* str); } - -#endif // REVERSE_STRING_H ``` **reverse_string.cpp** diff --git a/exercises/practice/reverse-string/.approaches/stack-operations/content.md b/exercises/practice/reverse-string/.approaches/stack-operations/content.md index 67b01c6c9..a2c35ac49 100644 --- a/exercises/practice/reverse-string/.approaches/stack-operations/content.md +++ b/exercises/practice/reverse-string/.approaches/stack-operations/content.md @@ -2,8 +2,7 @@ **reverse_string.h** ```cpp -#ifndef REVERSE_STRING_H -#define REVERSE_STRING_H +#pragma once #include @@ -11,8 +10,6 @@ namespace reverse_string { std::string reverse_string(std::string_view str); } - -#endif // REVERSE_STRING_H ``` **reverse_string.cpp** diff --git a/exercises/practice/reverse-string/.approaches/swapping-characters/content.md b/exercises/practice/reverse-string/.approaches/swapping-characters/content.md index 3fe360a83..a3e720934 100644 --- a/exercises/practice/reverse-string/.approaches/swapping-characters/content.md +++ b/exercises/practice/reverse-string/.approaches/swapping-characters/content.md @@ -2,8 +2,7 @@ **reverse_string.h** ```cpp -#ifndef REVERSE_STRING_H -#define REVERSE_STRING_H +#pragma once #include @@ -11,8 +10,6 @@ namespace reverse_string { std::string reverse_string(std::string str); } - -#endif // REVERSE_STRING_H ``` **reverse_string.cpp** diff --git a/exercises/practice/reverse-string/.approaches/using-the-standard-lib/content.md b/exercises/practice/reverse-string/.approaches/using-the-standard-lib/content.md index 97d02a0fe..837350d42 100644 --- a/exercises/practice/reverse-string/.approaches/using-the-standard-lib/content.md +++ b/exercises/practice/reverse-string/.approaches/using-the-standard-lib/content.md @@ -2,8 +2,7 @@ **reverse_string.h** ```cpp -#ifndef REVERSE_STRING_H -#define REVERSE_STRING_H +#pragma once #include @@ -11,8 +10,6 @@ namespace reverse_string { std::string reverse_string(std::string str); } - -#endif // REVERSE_STRING_H ``` **reverse_string.cpp** diff --git a/exercises/practice/reverse-string/.meta/example.h b/exercises/practice/reverse-string/.meta/example.h index 07ffac7c2..8ca790edf 100644 --- a/exercises/practice/reverse-string/.meta/example.h +++ b/exercises/practice/reverse-string/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(REVERSE_STRING_H) -#define REVERSE_STRING_H +#pragma once #include @@ -8,5 +7,3 @@ namespace reverse_string { std::string reverse_string(const std::string& text); } - -#endif diff --git a/exercises/practice/reverse-string/reverse_string.h b/exercises/practice/reverse-string/reverse_string.h index 67be650d9..0a5daedf2 100644 --- a/exercises/practice/reverse-string/reverse_string.h +++ b/exercises/practice/reverse-string/reverse_string.h @@ -1,10 +1,7 @@ -#if !defined(REVERSE_STRING_H) -#define REVERSE_STRING_H +#pragma once namespace reverse_string { // TODO: add your solution here } // namespace reverse_string - -#endif // REVERSE_STRING_H \ No newline at end of file diff --git a/exercises/practice/rna-transcription/.meta/example.h b/exercises/practice/rna-transcription/.meta/example.h index 84347f393..5b1c57764 100644 --- a/exercises/practice/rna-transcription/.meta/example.h +++ b/exercises/practice/rna-transcription/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(RNA_TRANSCRIPTION_H) -#define RNA_TRANSCRIPTION_H +#pragma once #include @@ -9,5 +8,3 @@ char to_rna(char nucleotide); std::string to_rna(std::string const& nucleotide); } // namespace rna_transcription - -#endif diff --git a/exercises/practice/rna-transcription/rna_transcription.h b/exercises/practice/rna-transcription/rna_transcription.h index 0dd584039..aa3cb66ce 100644 --- a/exercises/practice/rna-transcription/rna_transcription.h +++ b/exercises/practice/rna-transcription/rna_transcription.h @@ -1,10 +1,7 @@ -#if !defined(RNA_TRANSCRIPTION_H) -#define RNA_TRANSCRIPTION_H +#pragma once namespace rna_transcription { // TODO: add your solution here } // namespace rna_transcription - -#endif // RNA_TRANSCRIPTION_H \ No newline at end of file diff --git a/exercises/practice/robot-name/.meta/example.h b/exercises/practice/robot-name/.meta/example.h index ef941b679..c289a1ee1 100644 --- a/exercises/practice/robot-name/.meta/example.h +++ b/exercises/practice/robot-name/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(ROBOT_NAME_H) -#define ROBOT_NAME_H +#pragma once #include @@ -18,5 +17,3 @@ class robot { }; } // namespace robot_name - -#endif diff --git a/exercises/practice/robot-name/robot_name.h b/exercises/practice/robot-name/robot_name.h index 2100ebd1c..ee0809a8e 100644 --- a/exercises/practice/robot-name/robot_name.h +++ b/exercises/practice/robot-name/robot_name.h @@ -1,10 +1,7 @@ -#if !defined(ROBOT_NAME_H) -#define ROBOT_NAME_H +#pragma once namespace robot_name { // TODO: add your solution here } // namespace robot_name - -#endif // ROBOT_NAME_H \ No newline at end of file diff --git a/exercises/practice/robot-simulator/.meta/example.h b/exercises/practice/robot-simulator/.meta/example.h index 6fc92cb86..d6b3e226b 100644 --- a/exercises/practice/robot-simulator/.meta/example.h +++ b/exercises/practice/robot-simulator/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(ROBOT_SIMULATOR_H) -#define ROBOT_SIMULATOR_H +#pragma once #include #include @@ -29,5 +28,3 @@ class Robot { }; } // namespace robot_simulator - -#endif // ROBOT_SIMULATOR diff --git a/exercises/practice/robot-simulator/robot_simulator.h b/exercises/practice/robot-simulator/robot_simulator.h index 5a9faaef9..80db2b0b7 100644 --- a/exercises/practice/robot-simulator/robot_simulator.h +++ b/exercises/practice/robot-simulator/robot_simulator.h @@ -1,10 +1,7 @@ -#if !defined(ROBOT_SIMULATOR_H) -#define ROBOT_SIMULATOR_H +#pragma once namespace robot_simulator { // TODO: add your solution here } // namespace robot_simulator - -#endif // ROBOT_SIMULATOR_H \ No newline at end of file diff --git a/exercises/practice/roman-numerals/.meta/example.h b/exercises/practice/roman-numerals/.meta/example.h index b4d0926eb..4f90f8f86 100644 --- a/exercises/practice/roman-numerals/.meta/example.h +++ b/exercises/practice/roman-numerals/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(ROMAN_NUMERALS_H) -#define ROMAN_NUMERALS_H +#pragma once #include @@ -8,5 +7,3 @@ namespace roman_numerals { std::string convert(int n); } - -#endif diff --git a/exercises/practice/roman-numerals/roman_numerals.h b/exercises/practice/roman-numerals/roman_numerals.h index 473d1b7d0..1fb2a17aa 100644 --- a/exercises/practice/roman-numerals/roman_numerals.h +++ b/exercises/practice/roman-numerals/roman_numerals.h @@ -1,6 +1,3 @@ -#if !defined(ROMAN_NUMERALS_H) -#define ROMAN_NUMERALS_H +#pragma once namespace roman_numerals {} // namespace roman_numerals - -#endif // ROMAN_NUMERALS_H \ No newline at end of file diff --git a/exercises/practice/say/.meta/example.h b/exercises/practice/say/.meta/example.h index 640da0abe..ab8eb6015 100644 --- a/exercises/practice/say/.meta/example.h +++ b/exercises/practice/say/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(SAY_H) -#define SAY_H +#pragma once #include @@ -8,5 +7,3 @@ namespace say { std::string in_english(unsigned long long number); } - -#endif diff --git a/exercises/practice/say/say.h b/exercises/practice/say/say.h index cc99e7f4a..2c24dcda4 100644 --- a/exercises/practice/say/say.h +++ b/exercises/practice/say/say.h @@ -1,10 +1,7 @@ -#if !defined(SAY_H) -#define SAY_H +#pragma once namespace say { // TODO: add your solution here } // namespace say - -#endif // SAY_H \ No newline at end of file diff --git a/exercises/practice/scrabble-score/.meta/example.h b/exercises/practice/scrabble-score/.meta/example.h index 0163ef4b9..1f72d8bff 100644 --- a/exercises/practice/scrabble-score/.meta/example.h +++ b/exercises/practice/scrabble-score/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(SCRABBLE_SCORE_H) -#define SCRABBLE_SCORE_H +#pragma once #include @@ -8,5 +7,3 @@ namespace scrabble_score { int score(const std::string &word); } - -#endif diff --git a/exercises/practice/scrabble-score/scrabble_score.h b/exercises/practice/scrabble-score/scrabble_score.h index b188eace0..1bd24fa06 100644 --- a/exercises/practice/scrabble-score/scrabble_score.h +++ b/exercises/practice/scrabble-score/scrabble_score.h @@ -1,10 +1,7 @@ -#if !defined(SCRABBLE_SCORE_H) -#define SCRABBLE_SCORE_H +#pragma once namespace scrabble_score { // TODO: add your solution here } // namespace scrabble_score - -#endif // SCRABBLE_SCORE_H \ No newline at end of file diff --git a/exercises/practice/secret-handshake/.approaches/if-statements-with-reverse/content.md b/exercises/practice/secret-handshake/.approaches/if-statements-with-reverse/content.md index 057d661f8..2e78fa99c 100644 --- a/exercises/practice/secret-handshake/.approaches/if-statements-with-reverse/content.md +++ b/exercises/practice/secret-handshake/.approaches/if-statements-with-reverse/content.md @@ -2,16 +2,13 @@ **secret_handshake.h** ```cpp -#if !defined(SECRET_HANDSHAKE_H) -#define SECRET_HANDSHAKE_H +#pragma once #include #include namespace secret_handshake { std::vector commands (unsigned int signal); } // namespace secret_handshake - -#endif // SECRET_HANDSHAKE_H ``` **secret_handshake.cpp** diff --git a/exercises/practice/secret-handshake/.approaches/introduction.md b/exercises/practice/secret-handshake/.approaches/introduction.md index b6f8044f6..7f1244565 100644 --- a/exercises/practice/secret-handshake/.approaches/introduction.md +++ b/exercises/practice/secret-handshake/.approaches/introduction.md @@ -8,16 +8,13 @@ Another general approach is to iterate once even if the actions are meant to be **secret_handshake.h** ```cpp -#if !defined(SECRET_HANDSHAKE_H) -#define SECRET_HANDSHAKE_H +#pragma once #include #include namespace secret_handshake { std::vector commands (unsigned int signal); } // namespace secret_handshake - -#endif // SECRET_HANDSHAKE_H ``` **secret_handshake.cpp** @@ -46,16 +43,13 @@ For more information, check the [`if` statements with `reverse()` approach][appr **secret_handshake.h** ```cpp -#if !defined(SECRET_HANDSHAKE_H) -#define SECRET_HANDSHAKE_H +#pragma once #include #include namespace secret_handshake { std::vector commands (unsigned int signal); } // namespace secret_handshake - -#endif // SECRET_HANDSHAKE_H ``` **secret_handshake.cpp** diff --git a/exercises/practice/secret-handshake/.approaches/iterate-once/content.md b/exercises/practice/secret-handshake/.approaches/iterate-once/content.md index fc0958a88..ee1f6b87b 100644 --- a/exercises/practice/secret-handshake/.approaches/iterate-once/content.md +++ b/exercises/practice/secret-handshake/.approaches/iterate-once/content.md @@ -2,16 +2,13 @@ **secret_handshake.h** ```cpp -#if !defined(SECRET_HANDSHAKE_H) -#define SECRET_HANDSHAKE_H +#pragma once #include #include namespace secret_handshake { std::vector commands (unsigned int signal); } // namespace secret_handshake - -#endif // SECRET_HANDSHAKE_H ``` **secret_handshake.cpp** diff --git a/exercises/practice/secret-handshake/.meta/example.h b/exercises/practice/secret-handshake/.meta/example.h index f32ece3be..aa5de19da 100644 --- a/exercises/practice/secret-handshake/.meta/example.h +++ b/exercises/practice/secret-handshake/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(SECRET_HANDSHAKE_H_) -#define SECRET_HANDSHAKE_H_ +#pragma once #include #include @@ -9,5 +8,3 @@ namespace secret_handshake { std::vector commands(int value); } // namespace secret_handshake - -#endif // !SECRET_HANDSHAKE_H_ diff --git a/exercises/practice/secret-handshake/secret_handshake.h b/exercises/practice/secret-handshake/secret_handshake.h index e2c57cd33..1f34e092a 100644 --- a/exercises/practice/secret-handshake/secret_handshake.h +++ b/exercises/practice/secret-handshake/secret_handshake.h @@ -1,10 +1,7 @@ -#if !defined(SECRET_HANDSHAKE_H) -#define SECRET_HANDSHAKE_H +#pragma once namespace secret_handshake { // TODO: add your solution here } // namespace secret_handshake - -#endif // SECRET_HANDSHAKE_H diff --git a/exercises/practice/series/.meta/example.h b/exercises/practice/series/.meta/example.h index 0c9ce6819..d06d7112e 100644 --- a/exercises/practice/series/.meta/example.h +++ b/exercises/practice/series/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(SERIES_H) -#define SERIES_H +#pragma once #include #include @@ -11,5 +10,3 @@ std::string digits(const std::string &input); std::vector slice(const std::string &input, size_t window); } // namespace series - -#endif diff --git a/exercises/practice/series/series.h b/exercises/practice/series/series.h index 33d5c2a00..bd11e0a95 100644 --- a/exercises/practice/series/series.h +++ b/exercises/practice/series/series.h @@ -1,10 +1,7 @@ -#if !defined(SERIES_H) -#define SERIES_H +#pragma once namespace series { // TODO: add your solution here } // namespace series - -#endif // SERIES_H \ No newline at end of file diff --git a/exercises/practice/sieve/.approaches/introduction.md b/exercises/practice/sieve/.approaches/introduction.md index e3d4ccd5d..2b2a6be7a 100644 --- a/exercises/practice/sieve/.approaches/introduction.md +++ b/exercises/practice/sieve/.approaches/introduction.md @@ -11,13 +11,11 @@ Something to consider is to keep the number of allocations and iterations at a m **sieve.h** ```cpp -#if !defined(SIEVE_H) -#define SIEVE_H +#pragma once #include namespace sieve { std::vector primes(int); } // namespace sieve -#endif // SIEVE_H ``` **sieve.cpp** diff --git a/exercises/practice/sieve/.approaches/vector-of-bools/content.md b/exercises/practice/sieve/.approaches/vector-of-bools/content.md index 17949fee5..2af7ccfca 100644 --- a/exercises/practice/sieve/.approaches/vector-of-bools/content.md +++ b/exercises/practice/sieve/.approaches/vector-of-bools/content.md @@ -2,13 +2,11 @@ **sieve.h** ```cpp -#if !defined(SIEVE_H) -#define SIEVE_H +#pragma once #include namespace sieve { std::vector primes(int); } // namespace sieve -#endif // SIEVE_H ``` **sieve.cpp** diff --git a/exercises/practice/sieve/.meta/example.h b/exercises/practice/sieve/.meta/example.h index 4687f7598..ff9d216c2 100644 --- a/exercises/practice/sieve/.meta/example.h +++ b/exercises/practice/sieve/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(SIEVE_H) -#define SIEVE_H +#pragma once #include @@ -8,5 +7,3 @@ namespace sieve { std::vector primes(int n); } - -#endif diff --git a/exercises/practice/sieve/sieve.h b/exercises/practice/sieve/sieve.h index be453bdae..b27ed9ee0 100644 --- a/exercises/practice/sieve/sieve.h +++ b/exercises/practice/sieve/sieve.h @@ -1,10 +1,7 @@ -#if !defined(SIEVE_H) -#define SIEVE_H +#pragma once namespace sieve { // TODO: add your solution here } // namespace sieve - -#endif // SIEVE_H \ No newline at end of file diff --git a/exercises/practice/simple-linked-list/.meta/example.h b/exercises/practice/simple-linked-list/.meta/example.h index f173515fa..99605ed3b 100644 --- a/exercises/practice/simple-linked-list/.meta/example.h +++ b/exercises/practice/simple-linked-list/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(SIMPLE_LINKED_LIST_H) -#define SIMPLE_LINKED_LIST_H +#pragma once #include @@ -35,5 +34,3 @@ class List { }; } // namespace simple_linked_list - -#endif diff --git a/exercises/practice/simple-linked-list/simple_linked_list.h b/exercises/practice/simple-linked-list/simple_linked_list.h index f173515fa..99605ed3b 100644 --- a/exercises/practice/simple-linked-list/simple_linked_list.h +++ b/exercises/practice/simple-linked-list/simple_linked_list.h @@ -1,5 +1,4 @@ -#if !defined(SIMPLE_LINKED_LIST_H) -#define SIMPLE_LINKED_LIST_H +#pragma once #include @@ -35,5 +34,3 @@ class List { }; } // namespace simple_linked_list - -#endif diff --git a/exercises/practice/space-age/.meta/example.h b/exercises/practice/space-age/.meta/example.h index 303f397a6..4e26bc5db 100644 --- a/exercises/practice/space-age/.meta/example.h +++ b/exercises/practice/space-age/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(SPACE_AGE_H) -#define SPACE_AGE_H +#pragma once namespace space_age { @@ -22,5 +21,3 @@ class space_age { }; } // namespace space_age - -#endif diff --git a/exercises/practice/space-age/space_age.h b/exercises/practice/space-age/space_age.h index 24e06402c..fbfcf3a8a 100644 --- a/exercises/practice/space-age/space_age.h +++ b/exercises/practice/space-age/space_age.h @@ -1,10 +1,7 @@ -#if !defined(SPACE_AGE_H) -#define SPACE_AGE_H +#pragma once namespace space_age { // TODO: add your solution here } // namespace space_age - -#endif // SPACE_AGE_H \ No newline at end of file diff --git a/exercises/practice/spiral-matrix/.meta/example.h b/exercises/practice/spiral-matrix/.meta/example.h index 8c0cda416..26795f24b 100644 --- a/exercises/practice/spiral-matrix/.meta/example.h +++ b/exercises/practice/spiral-matrix/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(SPIRAL_MATRIX_H) -#define SPIRAL_MATRIX_H +#pragma once #include #include @@ -9,5 +8,3 @@ namespace spiral_matrix { [[nodiscard]] std::vector> spiral_matrix(uint32_t size); } // namespace spiral_matrix - -#endif // SPIRAL_MATRIX_H diff --git a/exercises/practice/spiral-matrix/spiral_matrix.h b/exercises/practice/spiral-matrix/spiral_matrix.h index 6efabea92..8cff8d81f 100644 --- a/exercises/practice/spiral-matrix/spiral_matrix.h +++ b/exercises/practice/spiral-matrix/spiral_matrix.h @@ -1,10 +1,7 @@ -#if !defined(SPIRAL_MATRIX_H) -#define SPIRAL_MATRIX_H +#pragma once namespace spiral_matrix { // TODO: add your solution here } // namespace spiral_matrix - -#endif // SPIRAL_MATRIX_H diff --git a/exercises/practice/sum-of-multiples/.meta/example.h b/exercises/practice/sum-of-multiples/.meta/example.h index 8b0b3d6ea..42bc3e3b3 100644 --- a/exercises/practice/sum-of-multiples/.meta/example.h +++ b/exercises/practice/sum-of-multiples/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(SUM_OF_MULTIPLES_H) -#define SUM_OF_MULTIPLES_H +#pragma once #include @@ -8,5 +7,3 @@ namespace sum_of_multiples { int to(std::initializer_list const& multiples, int num); } - -#endif diff --git a/exercises/practice/sum-of-multiples/sum_of_multiples.h b/exercises/practice/sum-of-multiples/sum_of_multiples.h index 54269f736..2b07e75c9 100644 --- a/exercises/practice/sum-of-multiples/sum_of_multiples.h +++ b/exercises/practice/sum-of-multiples/sum_of_multiples.h @@ -1,10 +1,7 @@ -#if !defined(SUM_OF_MULTIPLES_H) -#define SUM_OF_MULTIPLES_H +#pragma once namespace sum_of_multiples { // TODO: add your solution here } // namespace sum_of_multiples - -#endif // SUM_OF_MULTIPLES_H \ No newline at end of file diff --git a/exercises/practice/triangle/.meta/example.h b/exercises/practice/triangle/.meta/example.h index cd82173c3..b8b5b3f0c 100644 --- a/exercises/practice/triangle/.meta/example.h +++ b/exercises/practice/triangle/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(TRIANGLE_H) -#define TRIANGLE_H +#pragma once namespace triangle { @@ -8,5 +7,3 @@ enum class flavor { equilateral, isosceles, scalene }; flavor kind(double a, double b, double c); } // namespace triangle - -#endif diff --git a/exercises/practice/triangle/triangle.h b/exercises/practice/triangle/triangle.h index 4d541a43e..743ce1488 100644 --- a/exercises/practice/triangle/triangle.h +++ b/exercises/practice/triangle/triangle.h @@ -1,10 +1,7 @@ -#if !defined(TRIANGLE_H) -#define TRIANGLE_H +#pragma once namespace triangle { // TODO: add your solution here } // namespace triangle - -#endif // TRIANGLE_H \ No newline at end of file diff --git a/exercises/practice/trinary/.meta/example.h b/exercises/practice/trinary/.meta/example.h index d80592bfe..2d44b8a92 100644 --- a/exercises/practice/trinary/.meta/example.h +++ b/exercises/practice/trinary/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(TRINARY_H) -#define TRINARY_H +#pragma once #include @@ -8,5 +7,3 @@ namespace trinary { int to_decimal(std::string const &text); } - -#endif diff --git a/exercises/practice/trinary/trinary.h b/exercises/practice/trinary/trinary.h index 9940bd6c4..60a5dd6e1 100644 --- a/exercises/practice/trinary/trinary.h +++ b/exercises/practice/trinary/trinary.h @@ -1,10 +1,7 @@ -#if !defined(TRINARY_H) -#define TRINARY_H +#pragma once namespace trinary { // TODO: add your solution here } // namespace trinary - -#endif // TRINARY_H \ No newline at end of file diff --git a/exercises/practice/two-bucket/.meta/example.h b/exercises/practice/two-bucket/.meta/example.h index 38930db86..dd93285e4 100644 --- a/exercises/practice/two-bucket/.meta/example.h +++ b/exercises/practice/two-bucket/.meta/example.h @@ -1,5 +1,4 @@ -#ifndef TWO_BUCKET_H -#define TWO_BUCKET_H +#pragma once namespace two_bucket { @@ -15,5 +14,3 @@ measure_result measure(int bucket1_capacity, int bucket2_capacity, int target_volume, bucket_id start_bucket); } // namespace two_bucket - -#endif // TWO_BUCKET_H diff --git a/exercises/practice/two-bucket/two_bucket.h b/exercises/practice/two-bucket/two_bucket.h index 38930db86..dd93285e4 100644 --- a/exercises/practice/two-bucket/two_bucket.h +++ b/exercises/practice/two-bucket/two_bucket.h @@ -1,5 +1,4 @@ -#ifndef TWO_BUCKET_H -#define TWO_BUCKET_H +#pragma once namespace two_bucket { @@ -15,5 +14,3 @@ measure_result measure(int bucket1_capacity, int bucket2_capacity, int target_volume, bucket_id start_bucket); } // namespace two_bucket - -#endif // TWO_BUCKET_H diff --git a/exercises/practice/two-fer/.meta/example.h b/exercises/practice/two-fer/.meta/example.h index b206795df..43940b33e 100644 --- a/exercises/practice/two-fer/.meta/example.h +++ b/exercises/practice/two-fer/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(TWO_FER_H) -#define TWO_FER_H +#pragma once #include @@ -8,5 +7,3 @@ inline std::string two_fer(const std::string& name = "you") { return "One for " + name + ", one for me."; } } // namespace two_fer - -#endif // TWO_FER_H diff --git a/exercises/practice/two-fer/two_fer.h b/exercises/practice/two-fer/two_fer.h index b85179032..931a10153 100644 --- a/exercises/practice/two-fer/two_fer.h +++ b/exercises/practice/two-fer/two_fer.h @@ -1,10 +1,7 @@ -#if !defined(TWO_FER_H) -#define TWO_FER_H +#pragma once namespace two_fer { // TODO: add your solution here } // namespace two_fer - -#endif // TWO_FER_H diff --git a/exercises/practice/word-count/.meta/example.h b/exercises/practice/word-count/.meta/example.h index e8465d5bc..902d1b09d 100644 --- a/exercises/practice/word-count/.meta/example.h +++ b/exercises/practice/word-count/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(WORD_COUNT_H) -#define WORD_COUNT_H +#pragma once #include #include @@ -9,5 +8,3 @@ namespace word_count { std::map words(std::string const& text); } - -#endif diff --git a/exercises/practice/word-count/word_count.h b/exercises/practice/word-count/word_count.h index d3d8a74a0..a8aa20789 100644 --- a/exercises/practice/word-count/word_count.h +++ b/exercises/practice/word-count/word_count.h @@ -1,10 +1,7 @@ -#if !defined(WORD_COUNT_H) -#define WORD_COUNT_H +#pragma once namespace word_count { // TODO: add your solution here } // namespace word_count - -#endif // WORD_COUNT_H \ No newline at end of file diff --git a/exercises/practice/zebra-puzzle/.meta/example.h b/exercises/practice/zebra-puzzle/.meta/example.h index 64ad4bf3e..e8b27be81 100644 --- a/exercises/practice/zebra-puzzle/.meta/example.h +++ b/exercises/practice/zebra-puzzle/.meta/example.h @@ -1,5 +1,4 @@ -#if !defined(ZEBRA_PUZZLE_H) -#define ZEBRA_PUZZLE_H +#pragma once #include @@ -13,5 +12,3 @@ struct Solution { Solution solve(); } // namespace zebra_puzzle - -#endif diff --git a/exercises/practice/zebra-puzzle/zebra_puzzle.h b/exercises/practice/zebra-puzzle/zebra_puzzle.h index ec6711658..103fb35b1 100644 --- a/exercises/practice/zebra-puzzle/zebra_puzzle.h +++ b/exercises/practice/zebra-puzzle/zebra_puzzle.h @@ -1,5 +1,4 @@ -#if !defined(ZEBRA_PUZZLE_H) -#define ZEBRA_PUZZLE_H +#pragma once #include @@ -11,5 +10,3 @@ struct Solution { }; } // namespace zebra_puzzle - -#endif // ZEBRA_PUZZLE_H diff --git a/reference/exercise-concepts/anagram.md b/reference/exercise-concepts/anagram.md index 29aa71d3a..383c9bbc7 100644 --- a/reference/exercise-concepts/anagram.md +++ b/reference/exercise-concepts/anagram.md @@ -11,8 +11,7 @@ Given "listen" and a list of candidates like "enlists" "google" "inlets" "banana `anagram.h` ```cpp -#ifndef ANAGRAM_H -#define ANAGRAM_H +#pragma once #include #include @@ -28,8 +27,6 @@ private: }; } // namespace anagram - -#endif // !ANAGRAM_H ``` `anagram.cpp` diff --git a/reference/exercise-concepts/grains.md b/reference/exercise-concepts/grains.md index 50d3bc91b..b32ff7de7 100644 --- a/reference/exercise-concepts/grains.md +++ b/reference/exercise-concepts/grains.md @@ -18,8 +18,7 @@ Write code that shows: `grains.h` ```cpp -#ifndef GRAINS_H -#define GRAINS_H +#pragma once #include @@ -29,8 +28,6 @@ std::uint64_t square(std::uint8_t no); std::uint64_t total(); } - -#endif ``` `grains.cpp` diff --git a/reference/exercise-concepts/hamming.md b/reference/exercise-concepts/hamming.md index 50dacbf30..e1be9bb6c 100644 --- a/reference/exercise-concepts/hamming.md +++ b/reference/exercise-concepts/hamming.md @@ -9,8 +9,7 @@ Calculate the Hamming Distance between two strings. `hamming.h` ```cpp -#ifndef HAMMING_H -#define HAMMING_H +#pragma once #include @@ -18,8 +17,6 @@ namespace hamming { std::size_t compute(const std::string& s1, const std::string& s2); } - -#endif ``` `hamming.cpp` diff --git a/reference/exercise-concepts/isogram.md b/reference/exercise-concepts/isogram.md index c0936604c..67b0fd2d9 100644 --- a/reference/exercise-concepts/isogram.md +++ b/reference/exercise-concepts/isogram.md @@ -20,8 +20,7 @@ The word `isograms`, however, is not an isogram, because the `s` repeats. `isogram.h` ```cpp -#ifndef ISOGRAM_H -#define ISOGRAM_H +#pragma once #include @@ -30,8 +29,6 @@ namespace isogram { bool is_isogram(const std::string& word); } // namespace isogram - -#endif // ISOGRAM_H ``` `isogram.cpp` diff --git a/reference/exercise-concepts/leap.md b/reference/exercise-concepts/leap.md index e4cedb4e2..9dc0a09be 100644 --- a/reference/exercise-concepts/leap.md +++ b/reference/exercise-concepts/leap.md @@ -9,15 +9,12 @@ Given a year, report if it is a leap year. `leap.h` ```cpp -#ifndef LEAP_H -#define LEAP_H +#pragma once namespace leap { bool is_leap_year(int year); } - -#endif ``` `leap.cpp` diff --git a/reference/exercise-concepts/pangram.md b/reference/exercise-concepts/pangram.md index 5036f99e0..b3a86d156 100644 --- a/reference/exercise-concepts/pangram.md +++ b/reference/exercise-concepts/pangram.md @@ -13,8 +13,7 @@ The alphabet used consists of ASCII letters a to z, inclusive, and is case insen `pangram.h` ```cpp -#ifndef PANGRAM_H -#define PANGRAM_H +#pragma once #include @@ -23,8 +22,6 @@ namespace pangram { bool is_pangram(const std::string& s); } // namespace pangram - -#endif // PANGRAM_H ``` `pangram.cpp` diff --git a/reference/exercise-concepts/raindrops.md b/reference/exercise-concepts/raindrops.md index 73b1b5307..130362443 100644 --- a/reference/exercise-concepts/raindrops.md +++ b/reference/exercise-concepts/raindrops.md @@ -22,8 +22,7 @@ The rules of `raindrops` are that if a given number: `raindrops.h` ```cpp -#if !defined(RAINDROPS_H) -#define RAINDROPS_H +#pragma once #include @@ -33,8 +32,6 @@ namespace raindrops std::string convert(int drops); } - -#endif ``` `raindrops.cpp` diff --git a/reference/exercise-concepts/reverse-string.md b/reference/exercise-concepts/reverse-string.md index b76dc7f3b..24a43cdc2 100644 --- a/reference/exercise-concepts/reverse-string.md +++ b/reference/exercise-concepts/reverse-string.md @@ -13,8 +13,7 @@ output: "looc" `reverse_string.h` ```cpp -#if !defined(REVERSE_STRING_H) -#define REVERSE_STRING_H +#pragma once #include @@ -24,8 +23,6 @@ namespace reverse_string std::string reverse_string(const std::string& text); } - -#endif ``` `reverse_string.cpp` diff --git a/reference/exercise-concepts/rna-transcription.md b/reference/exercise-concepts/rna-transcription.md index f3e33e4e7..2ff7e2ddf 100644 --- a/reference/exercise-concepts/rna-transcription.md +++ b/reference/exercise-concepts/rna-transcription.md @@ -25,8 +25,7 @@ each nucleotide with its complement: `rna_transcription.h"` ```cpp -#if !defined(RNA_TRANSCRIPTION_H) -#define RNA_TRANSCRIPTION_H +#pragma once #include @@ -37,8 +36,6 @@ char to_rna(char nucleotide); std::string to_rna(std::string const& nucleotide); } - -#endif ``` `rna_transcription.cpp` diff --git a/reference/exercise-concepts/scrabble-score.md b/reference/exercise-concepts/scrabble-score.md index 1c6fa2ca7..f27f37808 100644 --- a/reference/exercise-concepts/scrabble-score.md +++ b/reference/exercise-concepts/scrabble-score.md @@ -39,8 +39,7 @@ And to total: ## Example `scrabble_score.h` ```cpp -#if !defined(SCRABBLE_SCORE_H) -#define SCRABBLE_SCORE_H +#pragma once #include @@ -50,8 +49,6 @@ namespace scrabble_score int score(const std::string &word); } - -#endif ``` `example.cpp` diff --git a/reference/exercise-concepts/sieve.md b/reference/exercise-concepts/sieve.md index d0945fe2c..6e0c96459 100644 --- a/reference/exercise-concepts/sieve.md +++ b/reference/exercise-concepts/sieve.md @@ -26,8 +26,7 @@ Notice that this is a very specific algorithm, and the tests don't check that yo `sieve.h` ```cpp -#if !defined(SIEVE_H) -#define SIEVE_H +#pragma once #include @@ -35,8 +34,6 @@ namespace sieve { std::vector primes(int n) noexcept; } // namespace sieve - -#endif // SIEVE_H ``` `sieve.cpp` diff --git a/reference/exercise-concepts/space-age.md b/reference/exercise-concepts/space-age.md index 18ffe75e4..55821e439 100644 --- a/reference/exercise-concepts/space-age.md +++ b/reference/exercise-concepts/space-age.md @@ -20,8 +20,7 @@ So if you were told someone were 1,000,000,000 seconds old, you should be able t `space-age.h` ```cpp -#if !defined(SPACE_AGE_H) -#define SPACE_AGE_H +#pragma once namespace space_age { @@ -46,8 +45,6 @@ private: }; } - -#endif ``` `space_age.cpp` diff --git a/reference/exercise-concepts/sum-of-multiples.md b/reference/exercise-concepts/sum-of-multiples.md index 9c771adc5..f4bc06841 100644 --- a/reference/exercise-concepts/sum-of-multiples.md +++ b/reference/exercise-concepts/sum-of-multiples.md @@ -15,8 +15,7 @@ The sum of these multiples is 78. `sum_of_multiples.h` ```cpp -#if !defined(SUM_OF_MULTIPLES_H) -#define SUM_OF_MULTIPLES_H +#pragma once #include @@ -26,8 +25,6 @@ namespace sum_of_multiples int to(std::initializer_list const& multiples, int num); } - -#endif ``` `sum_of_multiples.cpp` diff --git a/reference/exercise-concepts/triangle.md b/reference/exercise-concepts/triangle.md index caa135673..68c57899a 100644 --- a/reference/exercise-concepts/triangle.md +++ b/reference/exercise-concepts/triangle.md @@ -17,8 +17,7 @@ A _scalene_ triangle has all sides of different lengths. `triangle.h` ```cpp -#if !defined(TRIANGLE_H) -#define TRIANGLE_H +#pragma once namespace triangle { @@ -33,8 +32,6 @@ enum class flavor flavor kind(double a, double b, double c); } - -#endif ``` `triangle.cpp` diff --git a/reference/exercise-concepts/trinary.md b/reference/exercise-concepts/trinary.md index d30d7897d..755cbecba 100644 --- a/reference/exercise-concepts/trinary.md +++ b/reference/exercise-concepts/trinary.md @@ -22,16 +22,13 @@ The last place in a trinary number is the 1's place. The second to last is the 3 `trinary.h` ```cpp -#if !defined(TRINARY_H) -#define TRINARY_H +#pragma once #include namespace trinary { unsigned int to_decimal(const std::string &s) noexcept; } // namespace trinary - -#endif // TRINARY_H ``` `trinary.cpp` diff --git a/reference/exercise-concepts/two-fer.md b/reference/exercise-concepts/two-fer.md index 9529dcf0d..b1d44863e 100644 --- a/reference/exercise-concepts/two-fer.md +++ b/reference/exercise-concepts/two-fer.md @@ -19,8 +19,7 @@ However, if the name is missing, return the string: `two_fer.h` ```cpp -#if !defined(TWO_FER_H) -#define TWO_FER_H +#pragma once #include @@ -28,8 +27,6 @@ namespace two_fer { std::string two_fer(const std::string& name = "you") noexcept; } - -#endif ``` `two_fer.cpp` diff --git a/reference/exercise-concepts/word-count.md b/reference/exercise-concepts/word-count.md index 31f5c4126..2996e4a96 100644 --- a/reference/exercise-concepts/word-count.md +++ b/reference/exercise-concepts/word-count.md @@ -37,8 +37,7 @@ fled: 1 `"word_count.h"` ```cpp -#if !defined(WORD_COUNT_H) -#define WORD_COUNT_H +#pragma once #include #include @@ -49,8 +48,6 @@ namespace word_count std::map words(std::string const& text); } - -#endif ``` `word_count.cpp` From 90677067073d0ff202f58e6d3add9273a3e63acd Mon Sep 17 00:00:00 2001 From: Isaac Good Date: Tue, 13 May 2025 01:25:22 -0700 Subject: [PATCH 02/32] Sync tests for exercise/practice/bob (#958) * Sync tests for exercise/practice/bob * fix: add uids --------- Co-authored-by: vaeng <34183939+vaeng@users.noreply.github.com> --- exercises/practice/bob/.meta/tests.toml | 18 +++++- exercises/practice/bob/bob_test.cpp | 75 ++++++++++++++++--------- 2 files changed, 63 insertions(+), 30 deletions(-) diff --git a/exercises/practice/bob/.meta/tests.toml b/exercises/practice/bob/.meta/tests.toml index 630485579..5299e2895 100644 --- a/exercises/practice/bob/.meta/tests.toml +++ b/exercises/practice/bob/.meta/tests.toml @@ -1,6 +1,13 @@ -# This is an auto-generated file. Regular comments will be removed when this -# file is regenerated. Regenerating will not touch any manually added keys, -# so comments can be added in a "comment" key. +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. [e162fead-606f-437a-a166-d051915cea8e] description = "stating something" @@ -64,6 +71,7 @@ description = "alternate silence" [66953780-165b-4e7e-8ce3-4bcb80b6385a] description = "multiple line question" +include = false [5371ef75-d9ea-4103-bcfa-2da973ddec1b] description = "starting with whitespace" @@ -76,3 +84,7 @@ description = "other whitespace" [12983553-8601-46a8-92fa-fcaa3bc4a2a0] description = "non-question ending with whitespace" + +[2c7278ac-f955-4eb4-bf8f-e33eb4116a15] +description = "multiple line question" +reimplements = "66953780-165b-4e7e-8ce3-4bcb80b6385a" diff --git a/exercises/practice/bob/bob_test.cpp b/exercises/practice/bob/bob_test.cpp index 9a9c07328..118b15a2b 100644 --- a/exercises/practice/bob/bob_test.cpp +++ b/exercises/practice/bob/bob_test.cpp @@ -7,97 +7,118 @@ // Bob exercise test case data version 1.4.0 -TEST_CASE("stating_something") { +TEST_CASE("stating_something", "[e162fead-606f-437a-a166-d051915cea8e]") { REQUIRE("Whatever." == bob::hey("Tom-ay-to, tom-aaaah-to.")); } #if defined(EXERCISM_RUN_ALL_TESTS) -TEST_CASE("shouting") { REQUIRE("Whoa, chill out!" == bob::hey("WATCH OUT!")); } +TEST_CASE("shouting", "[73a966dc-8017-47d6-bb32-cf07d1a5fcd9]") { + REQUIRE("Whoa, chill out!" == bob::hey("WATCH OUT!")); +} -TEST_CASE("shouting_gibberish") { +TEST_CASE("shouting_gibberish", "[d6c98afd-df35-4806-b55e-2c457c3ab748]") { REQUIRE("Whoa, chill out!" == bob::hey("FCECDFCAAB")); } -TEST_CASE("asking_a_question") { +TEST_CASE("asking_a_question", "[8a2e771d-d6f1-4e3f-b6c6-b41495556e37]") { REQUIRE("Sure." == bob::hey("Does this cryogenic chamber make me look fat?")); } -TEST_CASE("asking_a_numeric_question") { +TEST_CASE("asking_a_numeric_question", + "[81080c62-4e4d-4066-b30a-48d8d76920d9]") { REQUIRE("Sure." == bob::hey("You are, what, like 15?")); } -TEST_CASE("asking_gibberish") { REQUIRE("Sure." == bob::hey("fffbbcbeab?")); } +TEST_CASE("asking_gibberish", "[2a02716d-685b-4e2e-a804-2adaf281c01e]") { + REQUIRE("Sure." == bob::hey("fffbbcbeab?")); +} -TEST_CASE("talking_forcefully") { +TEST_CASE("talking_forcefully", "[c02f9179-ab16-4aa7-a8dc-940145c385f7]") { REQUIRE("Whatever." == bob::hey("Let's go make out behind the gym!")); } -TEST_CASE("using_acronyms_in_regular_speech") { +TEST_CASE("using_acronyms_in_regular_speech", + "[153c0e25-9bb5-4ec5-966e-598463658bcd]") { REQUIRE("Whatever." == bob::hey("It's OK if you don't want to go to the DMV.")); } -TEST_CASE("forceful_questions") { +TEST_CASE("forceful_questions", "[a5193c61-4a92-4f68-93e2-f554eb385ec6]") { REQUIRE("Calm down, I know what I'm doing!" == bob::hey("WHAT THE HELL WERE YOU THINKING?")); } -TEST_CASE("shouting_numbers") { +TEST_CASE("shouting_numbers", "[a20e0c54-2224-4dde-8b10-bd2cdd4f61bc]") { REQUIRE("Whoa, chill out!" == bob::hey("1, 2, 3 GO!")); } -TEST_CASE("no_letters") { REQUIRE("Whatever." == bob::hey("1, 2, 3")); } +TEST_CASE("no_letters", "[f7bc4b92-bdff-421e-a238-ae97f230ccac]") { + REQUIRE("Whatever." == bob::hey("1, 2, 3")); +} -TEST_CASE("question_with_no_letters") { REQUIRE("Sure." == bob::hey("4?")); } +TEST_CASE("question_with_no_letters", + "[bb0011c5-cd52-4a5b-8bfb-a87b6283b0e2]") { + REQUIRE("Sure." == bob::hey("4?")); +} -TEST_CASE("shouting_with_special_characters") { +TEST_CASE("shouting_with_special_characters", + "[496143c8-1c31-4c01-8a08-88427af85c66]") { REQUIRE("Whoa, chill out!" == bob::hey("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!")); } -TEST_CASE("shouting_with_no_exclamation_mark") { +TEST_CASE("shouting_with_no_exclamation_mark", + "[e6793c1c-43bd-4b8d-bc11-499aea73925f]") { REQUIRE("Whoa, chill out!" == bob::hey("I HATE THE DMV")); } -TEST_CASE("statement_containing_question_mark") { +TEST_CASE("statement_containing_question_mark", + "[aa8097cc-c548-4951-8856-14a404dd236a]") { REQUIRE("Whatever." == bob::hey("Ending with ? means a question.")); } -TEST_CASE("non_letters_with_question") { REQUIRE("Sure." == bob::hey(":) ?")); } +TEST_CASE("non_letters_with_question", + "[9bfc677d-ea3a-45f2-be44-35bc8fa3753e]") { + REQUIRE("Sure." == bob::hey(":) ?")); +} -TEST_CASE("prattling_on") { +TEST_CASE("prattling_on", "[8608c508-f7de-4b17-985b-811878b3cf45]") { REQUIRE("Sure." == bob::hey("Wait! Hang on. Are you going to be OK?")); } -TEST_CASE("silence") { REQUIRE("Fine. Be that way!" == bob::hey("")); } +TEST_CASE("silence", "[bc39f7c6-f543-41be-9a43-fd1c2f753fc0]") { + REQUIRE("Fine. Be that way!" == bob::hey("")); +} -TEST_CASE("prolonged_silence") { +TEST_CASE("prolonged_silence", "[d6c47565-372b-4b09-b1dd-c40552b8378b]") { REQUIRE("Fine. Be that way!" == bob::hey(" ")); } -TEST_CASE("alternate_silence") { +TEST_CASE("alternate_silence", "[4428f28d-4100-4d85-a902-e5a78cb0ecd3]") { REQUIRE("Fine. Be that way!" == bob::hey("\t\t\t\t\t\t\t\t\t\t")); } -TEST_CASE("multiple_line_question") { - REQUIRE("Whatever." == - bob::hey("\nDoes this cryogenic chamber make me look fat?\nNo.")); +TEST_CASE("multiple_line_question", "[2c7278ac-f955-4eb4-bf8f-e33eb4116a15]") { + REQUIRE("Sure." == + bob::hey("\nDoes this cryogenic chamber make\n me look fat?")); } -TEST_CASE("starting_with_whitespace") { +TEST_CASE("starting_with_whitespace", + "[5371ef75-d9ea-4103-bcfa-2da973ddec1b]") { REQUIRE("Whatever." == bob::hey(" hmmmmmmm...")); } -TEST_CASE("ending_with_whitespace") { +TEST_CASE("ending_with_whitespace", "[05b304d6-f83b-46e7-81e0-4cd3ca647900]") { REQUIRE("Sure." == bob::hey("Okay if like my spacebar quite a bit? ")); } -TEST_CASE("other_whitespace") { +TEST_CASE("other_whitespace", "[72bd5ad3-9b2f-4931-a988-dce1f5771de2]") { REQUIRE("Fine. Be that way!" == bob::hey("\n\r \t")); } -TEST_CASE("non_question_ending_with_whitespace") { +TEST_CASE("non_question_ending_with_whitespace", + "[12983553-8601-46a8-92fa-fcaa3bc4a2a0]") { REQUIRE("Whatever." == bob::hey("This is a statement ending with whitespace ")); } From f3ac72ada2a8099fc68ba2507c2993e7491c06b8 Mon Sep 17 00:00:00 2001 From: Isaac Good Date: Tue, 13 May 2025 04:45:43 -0700 Subject: [PATCH 03/32] Sync tests for exercise/practice/pig-latin (#960) * Sync tests for exercise/practice/pig-latin * fix: avoid line break in test case name --------- Co-authored-by: vaeng <34183939+vaeng@users.noreply.github.com> --- exercises/practice/pig-latin/.meta/tests.toml | 3 +++ exercises/practice/pig-latin/pig_latin_test.cpp | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/exercises/practice/pig-latin/.meta/tests.toml b/exercises/practice/pig-latin/.meta/tests.toml index c29168c5e..d524305b4 100644 --- a/exercises/practice/pig-latin/.meta/tests.toml +++ b/exercises/practice/pig-latin/.meta/tests.toml @@ -39,6 +39,9 @@ description = "first letter and ay are moved to the end of words that start with [bce94a7a-a94e-4e2b-80f4-b2bb02e40f71] description = "first letter and ay are moved to the end of words that start with consonants -> word beginning with q without a following u" +[e59dbbe8-ccee-4619-a8e9-ce017489bfc0] +description = "first letter and ay are moved to the end of words that start with consonants -> word beginning with consonant and vowel containing qu" + [c01e049a-e3e2-451c-bf8e-e2abb7e438b8] description = "some letter clusters are treated like a single consonant -> word beginning with ch" diff --git a/exercises/practice/pig-latin/pig_latin_test.cpp b/exercises/practice/pig-latin/pig_latin_test.cpp index 646723a4e..89c6ce7d4 100644 --- a/exercises/practice/pig-latin/pig_latin_test.cpp +++ b/exercises/practice/pig-latin/pig_latin_test.cpp @@ -91,6 +91,13 @@ TEST_CASE("y is treated like a vowel at the end of a consonant cluster", "[adc90017-1a12-4100-b595-e346105042c7]") { REQUIRE("ythmrhay" == pig_latin::translate("rhythm")); } +// clang-format off +TEST_CASE( + "first_letter_and_ay_are_moved_to_the_end_of_words_that_start_with_consonants_->_word_beginning_with_consonant_and_vowel_containing_qu", + "[e59dbbe8-ccee-4619-a8e9-ce017489bfc0]") { + REQUIRE("iquidlay" == pig_latin::translate("liquid")); +} +// clang-format on TEST_CASE("y as second letter in two letter word", "[29b4ca3d-efe5-4a95-9a54-8467f2e5e59a]") { From 2e4ccc1c28da7d30131172cda389bf7d5fd76688 Mon Sep 17 00:00:00 2001 From: Marcel Weikum Date: Tue, 13 May 2025 14:00:08 +0200 Subject: [PATCH 04/32] Added "alphametics" exercise (#972) * Added alphametics exercise to the track * Changed difficulty in config.json * Minor indent change in example.cpp * Changed guard to pragma * Added prerequisites and practices * Run pre-commit locally --- config.json | 18 + .../alphametics/.docs/instructions.md | 29 + .../practice/alphametics/.meta/config.json | 19 + .../practice/alphametics/.meta/example.cpp | 97 + .../practice/alphametics/.meta/example.h | 11 + .../practice/alphametics/.meta/tests.toml | 40 + exercises/practice/alphametics/CMakeLists.txt | 67 + .../practice/alphametics/alphametics.cpp | 7 + exercises/practice/alphametics/alphametics.h | 10 + .../practice/alphametics/alphametics_test.cpp | 163 + exercises/practice/alphametics/test/catch.hpp | 17937 ++++++++++++++++ .../practice/alphametics/test/tests-main.cpp | 2 + 12 files changed, 18400 insertions(+) create mode 100644 exercises/practice/alphametics/.docs/instructions.md create mode 100644 exercises/practice/alphametics/.meta/config.json create mode 100644 exercises/practice/alphametics/.meta/example.cpp create mode 100644 exercises/practice/alphametics/.meta/example.h create mode 100644 exercises/practice/alphametics/.meta/tests.toml create mode 100644 exercises/practice/alphametics/CMakeLists.txt create mode 100644 exercises/practice/alphametics/alphametics.cpp create mode 100644 exercises/practice/alphametics/alphametics.h create mode 100644 exercises/practice/alphametics/alphametics_test.cpp create mode 100644 exercises/practice/alphametics/test/catch.hpp create mode 100644 exercises/practice/alphametics/test/tests-main.cpp diff --git a/config.json b/config.json index af802c182..0ffba9817 100644 --- a/config.json +++ b/config.json @@ -1244,6 +1244,24 @@ "strings" ], "difficulty": 4 + }, + { + "slug": "alphametics", + "name": "Alphametics", + "uuid": "0c69f8bd-c99a-4cb2-b113-82deaf0915ee", + "practices": [ + "auto", + "literals" + ], + "prerequisites": [ + "includes", + "namespaces", + "if-statements", + "booleans", + "headers", + "comparisons" + ], + "difficulty": 6 } ], "foregone": [ diff --git a/exercises/practice/alphametics/.docs/instructions.md b/exercises/practice/alphametics/.docs/instructions.md new file mode 100644 index 000000000..ef2cbb4a7 --- /dev/null +++ b/exercises/practice/alphametics/.docs/instructions.md @@ -0,0 +1,29 @@ +# Instructions + +Given an alphametics puzzle, find the correct solution. + +[Alphametics][alphametics] is a puzzle where letters in words are replaced with numbers. + +For example `SEND + MORE = MONEY`: + +```text + S E N D + M O R E + +----------- +M O N E Y +``` + +Replacing these with valid numbers gives: + +```text + 9 5 6 7 + 1 0 8 5 + +----------- +1 0 6 5 2 +``` + +This is correct because every letter is replaced by a different number and the words, translated into numbers, then make a valid sum. + +Each letter must represent a different digit, and the leading digit of a multi-digit number must not be zero. + +[alphametics]: https://en.wikipedia.org/wiki/Alphametics diff --git a/exercises/practice/alphametics/.meta/config.json b/exercises/practice/alphametics/.meta/config.json new file mode 100644 index 000000000..4e31974f0 --- /dev/null +++ b/exercises/practice/alphametics/.meta/config.json @@ -0,0 +1,19 @@ +{ + "authors": [ + "marcelweikum" + ], + "files": { + "solution": [ + "alphametics.cpp", + "alphametics.h" + ], + "test": [ + "alphametics_test.cpp" + ], + "example": [ + ".meta/example.cpp", + ".meta/example.h" + ] + }, + "blurb": "Given an alphametics puzzle, find the correct solution." +} diff --git a/exercises/practice/alphametics/.meta/example.cpp b/exercises/practice/alphametics/.meta/example.cpp new file mode 100644 index 000000000..3fc6eb0e2 --- /dev/null +++ b/exercises/practice/alphametics/.meta/example.cpp @@ -0,0 +1,97 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "alphametics.h" + +namespace alphametics { + +std::optional> solve(const std::string& puzzle) { + auto sep = puzzle.find("=="); + if (sep == std::string::npos) return std::nullopt; + std::string left = puzzle.substr(0, sep); + std::string right = puzzle.substr(sep + 2); + + auto trim = [&](std::string& s) { + auto b = s.find_first_not_of(' '); + auto e = s.find_last_not_of(' '); + s = (b == std::string::npos) ? std::string() : s.substr(b, e - b + 1); + }; + trim(left); + trim(right); + + std::vector addends; + std::istringstream iss(left); + for (std::string part; std::getline(iss, part, '+');) { + trim(part); + addends.push_back(part); + } + trim(right); + std::string result = right; + + std::vector letters; + std::unordered_set seen, leading; + auto collect = [&](const std::string& w) { + if (w.size() > 1) leading.insert(w.front()); + for (char c : w) { + if (seen.insert(c).second) letters.push_back(c); + } + }; + for (auto& w : addends) collect(w); + collect(result); + if (letters.size() > 10) return std::nullopt; + + int n = letters.size(); + std::map idx; + for (int i = 0; i < n; ++i) idx[letters[i]] = i; + std::vector weight(n, 0); + + for (auto& w : addends) { + long long mult = 1; + for (int i = (int)w.size() - 1; i >= 0; --i) { + weight[idx[w[i]]] += mult; + mult *= 10; + } + } + { + long long mult = 1; + for (int i = (int)result.size() - 1; i >= 0; --i) { + weight[idx[result[i]]] -= mult; + mult *= 10; + } + } + + std::vector used(10, false); + std::map assign; + bool found = false; + std::map solution; + std::function dfs = [&](int pos, long long sum) { + if (found) return; + if (pos == n) { + if (sum == 0) { + found = true; + solution = assign; + } + return; + } + char c = letters[pos]; + for (int d = 0; d < 10 && !found; ++d) { + if (used[d] || (d == 0 && leading.count(c))) continue; + used[d] = true; + assign[c] = d; + dfs(pos + 1, sum + weight[pos] * d); + used[d] = false; + } + }; + + dfs(0, 0); + if (found) return solution; + return std::nullopt; +} + +} // namespace alphametics diff --git a/exercises/practice/alphametics/.meta/example.h b/exercises/practice/alphametics/.meta/example.h new file mode 100644 index 000000000..9fc3bb6ed --- /dev/null +++ b/exercises/practice/alphametics/.meta/example.h @@ -0,0 +1,11 @@ +#pragma once + +#include +#include +#include + +namespace alphametics { + +std::optional> solve(const std::string& puzzle); + +} // namespace alphametics \ No newline at end of file diff --git a/exercises/practice/alphametics/.meta/tests.toml b/exercises/practice/alphametics/.meta/tests.toml new file mode 100644 index 000000000..f599b3da6 --- /dev/null +++ b/exercises/practice/alphametics/.meta/tests.toml @@ -0,0 +1,40 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[e0c08b07-9028-4d5f-91e1-d178fead8e1a] +description = "puzzle with three letters" + +[a504ee41-cb92-4ec2-9f11-c37e95ab3f25] +description = "solution must have unique value for each letter" + +[4e3b81d2-be7b-4c5c-9a80-cd72bc6d465a] +description = "leading zero solution is invalid" + +[8a3e3168-d1ee-4df7-94c7-b9c54845ac3a] +description = "puzzle with two digits final carry" + +[a9630645-15bd-48b6-a61e-d85c4021cc09] +description = "puzzle with four letters" + +[3d905a86-5a52-4e4e-bf80-8951535791bd] +description = "puzzle with six letters" + +[4febca56-e7b7-4789-97b9-530d09ba95f0] +description = "puzzle with seven letters" + +[12125a75-7284-4f9a-a5fa-191471e0d44f] +description = "puzzle with eight letters" + +[fb05955f-38dc-477a-a0b6-5ef78969fffa] +description = "puzzle with ten letters" + +[9a101e81-9216-472b-b458-b513a7adacf7] +description = "puzzle with ten letters and 199 addends" diff --git a/exercises/practice/alphametics/CMakeLists.txt b/exercises/practice/alphametics/CMakeLists.txt new file mode 100644 index 000000000..dba98a931 --- /dev/null +++ b/exercises/practice/alphametics/CMakeLists.txt @@ -0,0 +1,67 @@ +# Get the exercise name from the current directory +get_filename_component(exercise ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# Basic CMake project +cmake_minimum_required(VERSION 3.5.1) + +# Name the project after the exercise +project(${exercise} CXX) + +# Get a source filename from the exercise name by replacing -'s with _'s +string(REPLACE "-" "_" file ${exercise}) + +# Implementation could be only a header +if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.cpp) + set(exercise_cpp ${file}.cpp) +else() + set(exercise_cpp "") +endif() + +# Use the common Catch library? +if(EXERCISM_COMMON_CATCH) + # For Exercism track development only + add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h $) +elseif(EXERCISM_TEST_SUITE) + # The Exercism test suite is being run, the Docker image already + # includes a pre-built version of Catch. + find_package(Catch2 REQUIRED) + add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h) + target_link_libraries(${exercise} PRIVATE Catch2::Catch2WithMain) + # When Catch is installed system wide we need to include a different + # header, we need this define to use the correct one. + target_compile_definitions(${exercise} PRIVATE EXERCISM_TEST_SUITE) +else() + # Build executable from sources and headers + add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h test/tests-main.cpp) +endif() + +set_target_properties(${exercise} PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED OFF + CXX_EXTENSIONS OFF +) + +set(CMAKE_BUILD_TYPE Debug) + +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") + set_target_properties(${exercise} PROPERTIES + COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" + ) +endif() + +# Configure to run all the tests? +if(${EXERCISM_RUN_ALL_TESTS}) + target_compile_definitions(${exercise} PRIVATE EXERCISM_RUN_ALL_TESTS) +endif() + +# Tell MSVC not to warn us about unchecked iterators in debug builds +# Treat warnings as errors +# Treat type conversion warnings C4244 and C4267 as level 4 warnings, i.e. ignore them in level 3 +if(${MSVC}) + set_target_properties(${exercise} PROPERTIES + COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS + COMPILE_FLAGS "/WX /w44244 /w44267") +endif() + +# Run the tests on every build +add_custom_target(test_${exercise} ALL DEPENDS ${exercise} COMMAND ${exercise}) diff --git a/exercises/practice/alphametics/alphametics.cpp b/exercises/practice/alphametics/alphametics.cpp new file mode 100644 index 000000000..96a015394 --- /dev/null +++ b/exercises/practice/alphametics/alphametics.cpp @@ -0,0 +1,7 @@ +#include "alphametics.h" + +namespace alphametics { + +// TODO: add your solution here + +} // namespace alphametics diff --git a/exercises/practice/alphametics/alphametics.h b/exercises/practice/alphametics/alphametics.h new file mode 100644 index 000000000..bbbdf05d0 --- /dev/null +++ b/exercises/practice/alphametics/alphametics.h @@ -0,0 +1,10 @@ +#if !defined(ALPHAMETICS_H) +#define ALPHAMETICS_H + +namespace alphametics { + +// TODO: add your solution here + +} // namespace alphametics + +#endif // ALPHAMETICS_H \ No newline at end of file diff --git a/exercises/practice/alphametics/alphametics_test.cpp b/exercises/practice/alphametics/alphametics_test.cpp new file mode 100644 index 000000000..436ad1ee8 --- /dev/null +++ b/exercises/practice/alphametics/alphametics_test.cpp @@ -0,0 +1,163 @@ +#include "alphametics.h" +#ifdef EXERCISM_TEST_SUITE +#include +#else +#include "test/catch.hpp" +#endif + +TEST_CASE("puzzle_with_three_letters", + "[e0c08b07-9028-4d5f-91e1-d178fead8e1a]") { + auto result = alphametics::solve("I + BB == ILL"); + REQUIRE(result.has_value()); + auto m = *result; + REQUIRE(m.at('I') == 1); + REQUIRE(m.at('B') == 9); + REQUIRE(m.at('L') == 0); +} + +#if defined(EXERCISM_RUN_ALL_TESTS) + +TEST_CASE("solution_must_have_unique_value_for_each_letter", + "[a504ee41-cb92-4ec2-9f11-c37e95ab3f25]") { + auto result = alphametics::solve("A == B"); + REQUIRE_FALSE(result.has_value()); +} + +TEST_CASE("leading_zero_solution_is_invalid", + "[4e3b81d2-be7b-4c5c-9a80-cd72bc6d465a]") { + auto result = alphametics::solve("ACA + DD == BD"); + REQUIRE_FALSE(result.has_value()); +} + +TEST_CASE("puzzle_with_two_digits_final_carry", + "[8a3e3168-d1ee-4df7-94c7-b9c54845ac3a]") { + auto result = alphametics::solve( + "A + A + A + A + A + A + A + A + A + A + A + B == BCC"); + REQUIRE(result.has_value()); + auto m = *result; + REQUIRE(m.at('A') == 9); + REQUIRE(m.at('B') == 1); + REQUIRE(m.at('C') == 0); +} + +TEST_CASE("puzzle_with_four_letters", + "[a9630645-15bd-48b6-a61e-d85c4021cc09]") { + auto result = alphametics::solve("AS + A == MOM"); + REQUIRE(result.has_value()); + auto m = *result; + REQUIRE(m.at('A') == 9); + REQUIRE(m.at('S') == 2); + REQUIRE(m.at('M') == 1); + REQUIRE(m.at('O') == 0); +} + +TEST_CASE("puzzle_with_six_letters", "[3d905a86-5a52-4e4e-bf80-8951535791bd]") { + auto result = alphametics::solve("NO + NO + TOO == LATE"); + REQUIRE(result.has_value()); + auto m = *result; + REQUIRE(m.at('N') == 7); + REQUIRE(m.at('O') == 4); + REQUIRE(m.at('T') == 9); + REQUIRE(m.at('L') == 1); + REQUIRE(m.at('A') == 0); + REQUIRE(m.at('E') == 2); +} + +TEST_CASE("puzzle_with_seven_letters", + "[4febca56-e7b7-4789-97b9-530d09ba95f0]") { + auto result = alphametics::solve("HE + SEES + THE == LIGHT"); + REQUIRE(result.has_value()); + auto m = *result; + REQUIRE(m.at('E') == 4); + REQUIRE(m.at('G') == 2); + REQUIRE(m.at('H') == 5); + REQUIRE(m.at('I') == 0); + REQUIRE(m.at('L') == 1); + REQUIRE(m.at('S') == 9); + REQUIRE(m.at('T') == 7); +} + +TEST_CASE("puzzle_with_eight_letters", + "[12125a75-7284-4f9a-a5fa-191471e0d44f]") { + auto result = alphametics::solve("SEND + MORE == MONEY"); + REQUIRE(result.has_value()); + auto m = *result; + REQUIRE(m.at('S') == 9); + REQUIRE(m.at('E') == 5); + REQUIRE(m.at('N') == 6); + REQUIRE(m.at('D') == 7); + REQUIRE(m.at('M') == 1); + REQUIRE(m.at('O') == 0); + REQUIRE(m.at('R') == 8); + REQUIRE(m.at('Y') == 2); +} + +TEST_CASE("puzzle_with_ten_letters", "[fb05955f-38dc-477a-a0b6-5ef78969fffa]") { + auto result = alphametics::solve( + "AND + A + STRONG + OFFENSE + AS + A + GOOD == DEFENSE"); + REQUIRE(result.has_value()); + auto m = *result; + REQUIRE(m.at('A') == 5); + REQUIRE(m.at('D') == 3); + REQUIRE(m.at('E') == 4); + REQUIRE(m.at('F') == 7); + REQUIRE(m.at('G') == 8); + REQUIRE(m.at('N') == 0); + REQUIRE(m.at('O') == 2); + REQUIRE(m.at('R') == 1); + REQUIRE(m.at('S') == 6); + REQUIRE(m.at('T') == 9); +} + +TEST_CASE("puzzle_with_ten_letters_and_199_addends", + "[9a101e81-9216-472b-b458-b513a7adacf7]") { + auto result = alphametics::solve( + "THIS + A + FIRE + THEREFORE + FOR + ALL + HISTORIES + I + TELL + A + " + "TALE + " + "THAT + FALSIFIES + ITS + TITLE + TIS + A + LIE + THE + TALE + OF + " + "THE + LAST + " + "FIRE + HORSES + LATE + AFTER + THE + FIRST + FATHERS + FORESEE + THE " + "+ HORRORS + " + "THE + LAST + FREE + TROLL + TERRIFIES + THE + HORSES + OF + FIRE + " + "THE + TROLL + " + "RESTS + AT + THE + HOLE + OF + LOSSES + IT + IS + THERE + THAT + SHE " + "+ STORES + " + "ROLES + OF + LEATHERS + AFTER + SHE + SATISFIES + HER + HATE + OFF + " + "THOSE + FEARS + " + "A + TASTE + RISES + AS + SHE + HEARS + THE + LEAST + FAR + HORSE + " + "THOSE + FAST + " + "HORSES + THAT + FIRST + HEAR + THE + TROLL + FLEE + OFF + TO + THE + " + "FOREST + THE + " + "HORSES + THAT + ALERTS + RAISE + THE + STARES + OF + THE + OTHERS + " + "AS + THE + TROLL + " + "ASSAILS + AT + THE + TOTAL + SHIFT + HER + TEETH + TEAR + HOOF + OFF " + "+ TORSO + AS + THE + " + "LAST + HORSE + FORFEITS + ITS + LIFE + THE + FIRST + FATHERS + HEAR + " + "OF + THE + HORRORS + " + "THEIR + FEARS + THAT + THE + FIRES + FOR + THEIR + FEASTS + ARREST + " + "AS + THE + FIRST + " + "FATHERS + RESETTLE + THE + LAST + OF + THE + FIRE + HORSES + THE + " + "LAST + TROLL + HARASSES + " + "THE + FOREST + HEART + FREE + AT + LAST + OF + THE + LAST + TROLL + " + "ALL + OFFER + THEIR + " + "FIRE + HEAT + TO + THE + ASSISTERS + FAR + OFF + THE + TROLL + FASTS " + "+ ITS + LIFE + SHORTER + " + "AS + STARS + RISE + THE + HORSES + REST + SAFE + AFTER + ALL + SHARE " + "+ HOT + FISH + AS + " + "THEIR + AFFILIATES + TAILOR + A + ROOFS + FOR + THEIR + SAFE == " + "FORTRESSES"); + REQUIRE(result.has_value()); + auto m = *result; + REQUIRE(m.at('A') == 1); + REQUIRE(m.at('E') == 0); + REQUIRE(m.at('F') == 5); + REQUIRE(m.at('H') == 8); + REQUIRE(m.at('I') == 7); + REQUIRE(m.at('L') == 2); + REQUIRE(m.at('O') == 6); + REQUIRE(m.at('R') == 3); + REQUIRE(m.at('S') == 4); + REQUIRE(m.at('T') == 9); +} + +#endif \ No newline at end of file diff --git a/exercises/practice/alphametics/test/catch.hpp b/exercises/practice/alphametics/test/catch.hpp new file mode 100644 index 000000000..36eaeb27f --- /dev/null +++ b/exercises/practice/alphametics/test/catch.hpp @@ -0,0 +1,17937 @@ +/* + * Catch v2.13.6 + * Generated: 2021-04-16 18:23:38.044268 + * ---------------------------------------------------------- + * This file has been merged from multiple headers. Please don't edit it directly + * Copyright (c) 2021 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED +#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED +// start catch.hpp + + +#define CATCH_VERSION_MAJOR 2 +#define CATCH_VERSION_MINOR 13 +#define CATCH_VERSION_PATCH 6 + +#ifdef __clang__ +# pragma clang system_header +#elif defined __GNUC__ +# pragma GCC system_header +#endif + +// start catch_suppress_warnings.h + +#ifdef __clang__ +# ifdef __ICC // icpc defines the __clang__ macro +# pragma warning(push) +# pragma warning(disable: 161 1682) +# else // __ICC +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wpadded" +# pragma clang diagnostic ignored "-Wswitch-enum" +# pragma clang diagnostic ignored "-Wcovered-switch-default" +# endif +#elif defined __GNUC__ + // Because REQUIREs trigger GCC's -Wparentheses, and because still + // supported version of g++ have only buggy support for _Pragmas, + // Wparentheses have to be suppressed globally. +# pragma GCC diagnostic ignored "-Wparentheses" // See #674 for details + +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunused-variable" +# pragma GCC diagnostic ignored "-Wpadded" +#endif +// end catch_suppress_warnings.h +#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) +# define CATCH_IMPL +# define CATCH_CONFIG_ALL_PARTS +#endif + +// In the impl file, we want to have access to all parts of the headers +// Can also be used to sanely support PCHs +#if defined(CATCH_CONFIG_ALL_PARTS) +# define CATCH_CONFIG_EXTERNAL_INTERFACES +# if defined(CATCH_CONFIG_DISABLE_MATCHERS) +# undef CATCH_CONFIG_DISABLE_MATCHERS +# endif +# if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) +# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER +# endif +#endif + +#if !defined(CATCH_CONFIG_IMPL_ONLY) +// start catch_platform.h + +// See e.g.: +// https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html +#ifdef __APPLE__ +# include +# if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \ + (defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1) +# define CATCH_PLATFORM_MAC +# elif (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1) +# define CATCH_PLATFORM_IPHONE +# endif + +#elif defined(linux) || defined(__linux) || defined(__linux__) +# define CATCH_PLATFORM_LINUX + +#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) +# define CATCH_PLATFORM_WINDOWS +#endif + +// end catch_platform.h + +#ifdef CATCH_IMPL +# ifndef CLARA_CONFIG_MAIN +# define CLARA_CONFIG_MAIN_NOT_DEFINED +# define CLARA_CONFIG_MAIN +# endif +#endif + +// start catch_user_interfaces.h + +namespace Catch { + unsigned int rngSeed(); +} + +// end catch_user_interfaces.h +// start catch_tag_alias_autoregistrar.h + +// start catch_common.h + +// start catch_compiler_capabilities.h + +// Detect a number of compiler features - by compiler +// The following features are defined: +// +// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? +// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported? +// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported? +// CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled? +// **************** +// Note to maintainers: if new toggles are added please document them +// in configuration.md, too +// **************** + +// In general each macro has a _NO_ form +// (e.g. CATCH_CONFIG_NO_POSIX_SIGNALS) which disables the feature. +// Many features, at point of detection, define an _INTERNAL_ macro, so they +// can be combined, en-mass, with the _NO_ forms later. + +#ifdef __cplusplus + +# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) +# define CATCH_CPP14_OR_GREATER +# endif + +# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) +# define CATCH_CPP17_OR_GREATER +# endif + +#endif + +// Only GCC compiler should be used in this block, so other compilers trying to +// mask themselves as GCC should be ignored. +#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) && !defined(__LCC__) +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" ) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" ) + +# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) + +#endif + +#if defined(__clang__) + +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" ) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" ) + +// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug +// which results in calls to destructors being emitted for each temporary, +// without a matching initialization. In practice, this can result in something +// like `std::string::~string` being called on an uninitialized value. +// +// For example, this code will likely segfault under IBM XL: +// ``` +// REQUIRE(std::string("12") + "34" == "1234") +// ``` +// +// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented. +# if !defined(__ibmxl__) && !defined(__CUDACC__) +# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) */ +# endif + +# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ + _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") + +# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) + +# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" ) + +# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" ) + +# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wunused-template\"" ) + +#endif // __clang__ + +//////////////////////////////////////////////////////////////////////////////// +// Assume that non-Windows platforms support posix signals by default +#if !defined(CATCH_PLATFORM_WINDOWS) + #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS +#endif + +//////////////////////////////////////////////////////////////////////////////// +// We know some environments not to support full POSIX signals +#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__) + #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS +#endif + +#ifdef __OS400__ +# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS +# define CATCH_CONFIG_COLOUR_NONE +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Android somehow still does not support std::to_string +#if defined(__ANDROID__) +# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING +# define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Not all Windows environments support SEH properly +#if defined(__MINGW32__) +# define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH +#endif + +//////////////////////////////////////////////////////////////////////////////// +// PS4 +#if defined(__ORBIS__) +# define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Cygwin +#ifdef __CYGWIN__ + +// Required for some versions of Cygwin to declare gettimeofday +// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin +# define _BSD_SOURCE +// some versions of cygwin (most) do not support std::to_string. Use the libstd check. +// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813 +# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \ + && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)) + +# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING + +# endif +#endif // __CYGWIN__ + +//////////////////////////////////////////////////////////////////////////////// +// Visual C++ +#if defined(_MSC_VER) + +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) + +// Universal Windows platform does not support SEH +// Or console colours (or console at all...) +# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) +# define CATCH_CONFIG_COLOUR_NONE +# else +# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH +# endif + +// MSVC traditional preprocessor needs some workaround for __VA_ARGS__ +// _MSVC_TRADITIONAL == 0 means new conformant preprocessor +// _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor +# if !defined(__clang__) // Handle Clang masquerading for msvc +# if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) +# define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +# endif // MSVC_TRADITIONAL +# endif // __clang__ + +#endif // _MSC_VER + +#if defined(_REENTRANT) || defined(_MSC_VER) +// Enable async processing, as -pthread is specified or no additional linking is required +# define CATCH_INTERNAL_CONFIG_USE_ASYNC +#endif // _MSC_VER + +//////////////////////////////////////////////////////////////////////////////// +// Check if we are compiled with -fno-exceptions or equivalent +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +# define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED +#endif + +//////////////////////////////////////////////////////////////////////////////// +// DJGPP +#ifdef __DJGPP__ +# define CATCH_INTERNAL_CONFIG_NO_WCHAR +#endif // __DJGPP__ + +//////////////////////////////////////////////////////////////////////////////// +// Embarcadero C++Build +#if defined(__BORLANDC__) + #define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN +#endif + +//////////////////////////////////////////////////////////////////////////////// + +// Use of __COUNTER__ is suppressed during code analysis in +// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly +// handled by it. +// Otherwise all supported compilers support COUNTER macro, +// but user still might want to turn it off +#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) + #define CATCH_INTERNAL_CONFIG_COUNTER +#endif + +//////////////////////////////////////////////////////////////////////////////// + +// RTX is a special version of Windows that is real time. +// This means that it is detected as Windows, but does not provide +// the same set of capabilities as real Windows does. +#if defined(UNDER_RTSS) || defined(RTX64_BUILD) + #define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH + #define CATCH_INTERNAL_CONFIG_NO_ASYNC + #define CATCH_CONFIG_COLOUR_NONE +#endif + +#if !defined(_GLIBCXX_USE_C99_MATH_TR1) +#define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER +#endif + +// Various stdlib support checks that require __has_include +#if defined(__has_include) + // Check if string_view is available and usable + #if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW + #endif + + // Check if optional is available and usable + # if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL + # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) + + // Check if byte is available and usable + # if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # include + # if __cpp_lib_byte > 0 + # define CATCH_INTERNAL_CONFIG_CPP17_BYTE + # endif + # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) + + // Check if variant is available and usable + # if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # if defined(__clang__) && (__clang_major__ < 8) + // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852 + // fix should be in clang 8, workaround in libstdc++ 8.2 + # include + # if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) + # define CATCH_CONFIG_NO_CPP17_VARIANT + # else + # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT + # endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) + # else + # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT + # endif // defined(__clang__) && (__clang_major__ < 8) + # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) +#endif // defined(__has_include) + +#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) +# define CATCH_CONFIG_COUNTER +#endif +#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH) +# define CATCH_CONFIG_WINDOWS_SEH +#endif +// This is set by default, because we assume that unix compilers are posix-signal-compatible by default. +#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS) +# define CATCH_CONFIG_POSIX_SIGNALS +#endif +// This is set by default, because we assume that compilers with no wchar_t support are just rare exceptions. +#if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR) +# define CATCH_CONFIG_WCHAR +#endif + +#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING) +# define CATCH_CONFIG_CPP11_TO_STRING +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_CPP17_OPTIONAL) +# define CATCH_CONFIG_CPP17_OPTIONAL +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW) +# define CATCH_CONFIG_CPP17_STRING_VIEW +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT) +# define CATCH_CONFIG_CPP17_VARIANT +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && !defined(CATCH_CONFIG_CPP17_BYTE) +# define CATCH_CONFIG_CPP17_BYTE +#endif + +#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) +# define CATCH_INTERNAL_CONFIG_NEW_CAPTURE +#endif + +#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE) +# define CATCH_CONFIG_NEW_CAPTURE +#endif + +#if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) +# define CATCH_CONFIG_DISABLE_EXCEPTIONS +#endif + +#if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_POLYFILL_ISNAN) +# define CATCH_CONFIG_POLYFILL_ISNAN +#endif + +#if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC) && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && !defined(CATCH_CONFIG_NO_USE_ASYNC) && !defined(CATCH_CONFIG_USE_ASYNC) +# define CATCH_CONFIG_USE_ASYNC +#endif + +#if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE) +# define CATCH_CONFIG_ANDROID_LOGWRITE +#endif + +#if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) +# define CATCH_CONFIG_GLOBAL_NEXTAFTER +#endif + +// Even if we do not think the compiler has that warning, we still have +// to provide a macro that can be used by the code. +#if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION) +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION +#endif +#if !defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS +#endif + +// The goal of this macro is to avoid evaluation of the arguments, but +// still have the compiler warn on problems inside... +#if !defined(CATCH_INTERNAL_IGNORE_BUT_WARN) +# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) +#endif + +#if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10) +# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS +#elif defined(__clang__) && (__clang_major__ < 5) +# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS +#endif + +#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS +#endif + +#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) +#define CATCH_TRY if ((true)) +#define CATCH_CATCH_ALL if ((false)) +#define CATCH_CATCH_ANON(type) if ((false)) +#else +#define CATCH_TRY try +#define CATCH_CATCH_ALL catch (...) +#define CATCH_CATCH_ANON(type) catch (type) +#endif + +#if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) +#define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#endif + +// end catch_compiler_capabilities.h +#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line +#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) +#ifdef CATCH_CONFIG_COUNTER +# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) +#else +# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) +#endif + +#include +#include +#include + +// We need a dummy global operator<< so we can bring it into Catch namespace later +struct Catch_global_namespace_dummy {}; +std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); + +namespace Catch { + + struct CaseSensitive { enum Choice { + Yes, + No + }; }; + + class NonCopyable { + NonCopyable( NonCopyable const& ) = delete; + NonCopyable( NonCopyable && ) = delete; + NonCopyable& operator = ( NonCopyable const& ) = delete; + NonCopyable& operator = ( NonCopyable && ) = delete; + + protected: + NonCopyable(); + virtual ~NonCopyable(); + }; + + struct SourceLineInfo { + + SourceLineInfo() = delete; + SourceLineInfo( char const* _file, std::size_t _line ) noexcept + : file( _file ), + line( _line ) + {} + + SourceLineInfo( SourceLineInfo const& other ) = default; + SourceLineInfo& operator = ( SourceLineInfo const& ) = default; + SourceLineInfo( SourceLineInfo&& ) noexcept = default; + SourceLineInfo& operator = ( SourceLineInfo&& ) noexcept = default; + + bool empty() const noexcept { return file[0] == '\0'; } + bool operator == ( SourceLineInfo const& other ) const noexcept; + bool operator < ( SourceLineInfo const& other ) const noexcept; + + char const* file; + std::size_t line; + }; + + std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); + + // Bring in operator<< from global namespace into Catch namespace + // This is necessary because the overload of operator<< above makes + // lookup stop at namespace Catch + using ::operator<<; + + // Use this in variadic streaming macros to allow + // >> +StreamEndStop + // as well as + // >> stuff +StreamEndStop + struct StreamEndStop { + std::string operator+() const; + }; + template + T const& operator + ( T const& value, StreamEndStop ) { + return value; + } +} + +#define CATCH_INTERNAL_LINEINFO \ + ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) + +// end catch_common.h +namespace Catch { + + struct RegistrarForTagAliases { + RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); + }; + +} // end namespace Catch + +#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + +// end catch_tag_alias_autoregistrar.h +// start catch_test_registry.h + +// start catch_interfaces_testcase.h + +#include + +namespace Catch { + + class TestSpec; + + struct ITestInvoker { + virtual void invoke () const = 0; + virtual ~ITestInvoker(); + }; + + class TestCase; + struct IConfig; + + struct ITestCaseRegistry { + virtual ~ITestCaseRegistry(); + virtual std::vector const& getAllTests() const = 0; + virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; + }; + + bool isThrowSafe( TestCase const& testCase, IConfig const& config ); + bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); + std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); + std::vector const& getAllTestCasesSorted( IConfig const& config ); + +} + +// end catch_interfaces_testcase.h +// start catch_stringref.h + +#include +#include +#include +#include + +namespace Catch { + + /// A non-owning string class (similar to the forthcoming std::string_view) + /// Note that, because a StringRef may be a substring of another string, + /// it may not be null terminated. + class StringRef { + public: + using size_type = std::size_t; + using const_iterator = const char*; + + private: + static constexpr char const* const s_empty = ""; + + char const* m_start = s_empty; + size_type m_size = 0; + + public: // construction + constexpr StringRef() noexcept = default; + + StringRef( char const* rawChars ) noexcept; + + constexpr StringRef( char const* rawChars, size_type size ) noexcept + : m_start( rawChars ), + m_size( size ) + {} + + StringRef( std::string const& stdString ) noexcept + : m_start( stdString.c_str() ), + m_size( stdString.size() ) + {} + + explicit operator std::string() const { + return std::string(m_start, m_size); + } + + public: // operators + auto operator == ( StringRef const& other ) const noexcept -> bool; + auto operator != (StringRef const& other) const noexcept -> bool { + return !(*this == other); + } + + auto operator[] ( size_type index ) const noexcept -> char { + assert(index < m_size); + return m_start[index]; + } + + public: // named queries + constexpr auto empty() const noexcept -> bool { + return m_size == 0; + } + constexpr auto size() const noexcept -> size_type { + return m_size; + } + + // Returns the current start pointer. If the StringRef is not + // null-terminated, throws std::domain_exception + auto c_str() const -> char const*; + + public: // substrings and searches + // Returns a substring of [start, start + length). + // If start + length > size(), then the substring is [start, size()). + // If start > size(), then the substring is empty. + auto substr( size_type start, size_type length ) const noexcept -> StringRef; + + // Returns the current start pointer. May not be null-terminated. + auto data() const noexcept -> char const*; + + constexpr auto isNullTerminated() const noexcept -> bool { + return m_start[m_size] == '\0'; + } + + public: // iterators + constexpr const_iterator begin() const { return m_start; } + constexpr const_iterator end() const { return m_start + m_size; } + }; + + auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&; + auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; + + constexpr auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { + return StringRef( rawChars, size ); + } +} // namespace Catch + +constexpr auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { + return Catch::StringRef( rawChars, size ); +} + +// end catch_stringref.h +// start catch_preprocessor.hpp + + +#define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__ +#define CATCH_RECURSION_LEVEL1(...) CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL2(...) CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL3(...) CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL4(...) CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL5(...) CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(__VA_ARGS__))) + +#ifdef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__ +// MSVC needs more evaluations +#define CATCH_RECURSION_LEVEL6(...) CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__))) +#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__)) +#else +#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL5(__VA_ARGS__) +#endif + +#define CATCH_REC_END(...) +#define CATCH_REC_OUT + +#define CATCH_EMPTY() +#define CATCH_DEFER(id) id CATCH_EMPTY() + +#define CATCH_REC_GET_END2() 0, CATCH_REC_END +#define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2 +#define CATCH_REC_GET_END(...) CATCH_REC_GET_END1 +#define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT +#define CATCH_REC_NEXT1(test, next) CATCH_DEFER ( CATCH_REC_NEXT0 ) ( test, next, 0) +#define CATCH_REC_NEXT(test, next) CATCH_REC_NEXT1(CATCH_REC_GET_END test, next) + +#define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0) ) ( f, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST2(f, x, peek, ...) f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) + +#define CATCH_REC_LIST0_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST1_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0_UD) ) ( f, userdata, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST2_UD(f, userdata, x, peek, ...) f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) + +// Applies the function macro `f` to each of the remaining parameters, inserts commas between the results, +// and passes userdata as the first parameter to each invocation, +// e.g. CATCH_REC_LIST_UD(f, x, a, b, c) evaluates to f(x, a), f(x, b), f(x, c) +#define CATCH_REC_LIST_UD(f, userdata, ...) CATCH_RECURSE(CATCH_REC_LIST2_UD(f, userdata, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) + +#define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) + +#define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param) +#define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO## __VA_ARGS__ +#define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__ +#define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF +#define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__) +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__ +#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) +#else +// MSVC is adding extra space and needs another indirection to expand INTERNAL_CATCH_NOINTERNAL_CATCH_DEF +#define INTERNAL_CATCH_STRINGIZE2(...) INTERNAL_CATCH_STRINGIZE3(__VA_ARGS__) +#define INTERNAL_CATCH_STRINGIZE3(...) #__VA_ARGS__ +#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1) +#endif + +#define INTERNAL_CATCH_MAKE_NAMESPACE2(...) ns_##__VA_ARGS__ +#define INTERNAL_CATCH_MAKE_NAMESPACE(name) INTERNAL_CATCH_MAKE_NAMESPACE2(name) + +#define INTERNAL_CATCH_REMOVE_PARENS(...) INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__) + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) decltype(get_wrapper()) +#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)) +#else +#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) INTERNAL_CATCH_EXPAND_VARGS(decltype(get_wrapper())) +#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))) +#endif + +#define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...)\ + CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,__VA_ARGS__) + +#define INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_0) INTERNAL_CATCH_REMOVE_PARENS(_0) +#define INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_0, _1) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_1) +#define INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_0, _1, _2) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_1, _2) +#define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3) +#define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4) +#define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5) +#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _3, _4, _5, _6) +#define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7) +#define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8) +#define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9) +#define INTERNAL_CATCH_REMOVE_PARENS_11_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) + +#define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N + +#define INTERNAL_CATCH_TYPE_GEN\ + template struct TypeList {};\ + template\ + constexpr auto get_wrapper() noexcept -> TypeList { return {}; }\ + template class...> struct TemplateTypeList{};\ + template class...Cs>\ + constexpr auto get_wrapper() noexcept -> TemplateTypeList { return {}; }\ + template\ + struct append;\ + template\ + struct rewrap;\ + template class, typename...>\ + struct create;\ + template class, typename>\ + struct convert;\ + \ + template \ + struct append { using type = T; };\ + template< template class L1, typename...E1, template class L2, typename...E2, typename...Rest>\ + struct append, L2, Rest...> { using type = typename append, Rest...>::type; };\ + template< template class L1, typename...E1, typename...Rest>\ + struct append, TypeList, Rest...> { using type = L1; };\ + \ + template< template class Container, template class List, typename...elems>\ + struct rewrap, List> { using type = TypeList>; };\ + template< template class Container, template class List, class...Elems, typename...Elements>\ + struct rewrap, List, Elements...> { using type = typename append>, typename rewrap, Elements...>::type>::type; };\ + \ + template