Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
build/
.xmake
tests/test_main
tests/*.o
*.*~
Expand Down
1 change: 1 addition & 0 deletions .stylua.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
indent_type = "Spaces"
15 changes: 11 additions & 4 deletions examples/enum_to_string.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cstdio> // for std::puts

/* ELF Relocations */

#define ELF_RELOC(name, value) name = value,
Expand Down Expand Up @@ -57,12 +55,21 @@ ELF_RELOC(R_386_NUM, 43)

#ifndef SWITCH_VERSION

#ifdef FROZEN_VERSION
#include "frozen/map.h"
#ifdef FROZEN_STD_MODULE
import std;
#else
#include <cstdio>
#include <map>
#endif

#ifdef FROZEN_VERSION
#ifdef FROZEN_MODULE
import frozen;
#else
#include "frozen/map.h"
#endif
#endif

#ifdef FROZEN_VERSION
constexpr
frozen::map<RELOC_i386, const char*, 41>
Expand Down
20 changes: 15 additions & 5 deletions examples/enum_to_string_hash.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cstdio> // for std::puts

/* ELF Relocations */

#define ELF_RELOC(name, value) name = value,
Expand Down Expand Up @@ -55,14 +53,26 @@ ELF_RELOC(R_386_IRELATIVE, 42)
ELF_RELOC(R_386_NUM, 43)
};

#ifdef FROZEN_STD_MODULE
import std;
#else
#include <cstdio>
#include <unordered_map>
#endif

#ifdef FROZEN_VERSION
#include "frozen/unordered_map.h"
#include <frozen/bits/elsa.h> // this is not exported by the module

#ifdef FROZEN_MODULE
import frozen;
#else
#include <frozen/unordered_map.h>
#endif

namespace frozen {
template <> struct elsa<RELOC_i386> : elsa<int> {
};
}
#else
#include <unordered_map>
#endif

#ifdef FROZEN_VERSION
Expand Down
15 changes: 12 additions & 3 deletions examples/html_entities_map.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
#ifdef FROZEN_STD_MODULE
import std;
#else
#include <cstdint>
#include <utility>
#endif

#include <cinttypes>
#ifdef FROZEN_MODULE
import frozen;
#else
#include <frozen/unordered_map.h>
#include <frozen/string.h>
#endif

struct codes_t
{
uint32_t iCodepoint1;
uint32_t iCodepoint2{0};
std::uint32_t iCodepoint1;
std::uint32_t iCodepoint2{0};
};

static constexpr std::pair<frozen::string, codes_t> s_Entities[]
Expand Down
11 changes: 10 additions & 1 deletion examples/pixel_art.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@ g++ $0 -std=c++14 -Iinclude && ./a.out && rm -f a.out && qiv panda.ppm 1up.ppm
exit
#else

#ifdef FROZEN_STD_MODULE
import std;
#else
#include <array>
#include <frozen/map.h>
#include <fstream>
#endif

#ifdef FROZEN_MODULE
import frozen;
#else
#include <frozen/map.h>
#endif

constexpr frozen::map<char, std::array<char, 3>, 5> Tans{
{'R', {(char)0xFF, (char)0x00, (char)0x00}},
Expand Down
4 changes: 4 additions & 0 deletions examples/static_assert.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#ifdef FROZEN_MODULE
import frozen;
#else
#include <frozen/set.h>
#endif

static constexpr frozen::set<unsigned, 3> supported_sizes = {
1, 2, 4
Expand Down
13 changes: 11 additions & 2 deletions examples/value_modification.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#ifdef FROZEN_STD_MODULE
import std;
#else
#include <iostream>
#endif

#ifdef FROZEN_MODULE
import frozen;
#else
#include <frozen/set.h>
#include <frozen/string.h>
#include <frozen/unordered_map.h>
#include <iostream>
#endif

/// MAYBE_CONSTINIT expands to `constinit` if available.
#if __cpp_constinit
Expand Down Expand Up @@ -34,4 +43,4 @@ int main() {
auto range = fruits.equal_range("n_apples");
range.first->second = 1337;
std::cout << "n_apples: " << fruits.at("n_apples") << std::endl;
}
}
2 changes: 1 addition & 1 deletion include/frozen/algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ template <std::size_t size> class boyer_moore_searcher {
if (size == 0)
return { first, first };

if (size > size_t(last - first))
if (size > std::size_t(last - first))
return { last, last };

RandomAccessIterator iter = first + size - 1;
Expand Down
2 changes: 2 additions & 0 deletions include/frozen/bits/algorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@

#include "frozen/bits/basic_types.h"

#ifndef FROZEN_STD_MODULE
#include <limits>
#include <tuple>
#endif

namespace frozen {

Expand Down
2 changes: 2 additions & 0 deletions include/frozen/bits/basic_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
#include "frozen/bits/exceptions.h"
#include "frozen/bits/constexpr_assert.h"

#ifndef FROZEN_STD_MODULE
#include <array>
#include <utility>
#include <string>
#include <type_traits>
#endif

namespace frozen {

Expand Down
2 changes: 2 additions & 0 deletions include/frozen/bits/constexpr_assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
#ifndef FROZEN_LETITGO_CONSTEXPR_ASSERT_H
#define FROZEN_LETITGO_CONSTEXPR_ASSERT_H

#ifndef FROZEN_STD_MODULE
#include <cassert>
#include <utility>
#endif

inline void constexpr_assert_failed() {}

Expand Down
20 changes: 18 additions & 2 deletions include/frozen/bits/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,23 @@

// Code taken from https://stackoverflow.com/questions/43639122/which-values-can-msvc-lang-have
#if defined(FROZEN_LETITGO_IS_MSVC)
#if _MSVC_LANG > 201402
#if _MSVC_LANG > 201703L
#define FROZEN_LETITGO_HAS_CXX20 1
#else
#define FROZEN_LETITGO_HAS_CXX20 0
#endif
#if _MSVC_LANG > 201402L
#define FROZEN_LETITGO_HAS_CXX17 1
#else /* _MSVC_LANG > 201402 */
#define FROZEN_LETITGO_HAS_CXX17 0
#endif /* _MSVC_LANG > 201402 */
#else /* _MSVC_LANG etc. */
#if __cplusplus > 201402
#if __cplusplus > 201703L
#define FROZEN_LETITGO_HAS_CXX20 1
#else /* __cplusplus > 201402 */
#define FROZEN_LETITGO_HAS_CXX20 0
#endif /* __cplusplus > 201402 */
#if __cplusplus > 201402L
#define FROZEN_LETITGO_HAS_CXX17 1
#else /* __cplusplus > 201402 */
#define FROZEN_LETITGO_HAS_CXX17 0
Expand All @@ -51,6 +61,12 @@
#endif
#endif

#if FROZEN_LETITGO_HAS_CXX20 && __has_include(<compare>)
#if defined(_cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907
#define FROZEN_LETITGO_HAS_THREE_WAY_COMPARISON
#endif
#endif

#ifdef __cpp_char8_t
#define FROZEN_LETITGO_HAS_CHAR8T
#endif
Expand Down
2 changes: 2 additions & 0 deletions include/frozen/bits/elsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
#ifndef FROZEN_LETITGO_ELSA_H
#define FROZEN_LETITGO_ELSA_H

#ifndef FROZEN_STD_MODULE
#include <type_traits>
#endif

namespace frozen {

Expand Down
2 changes: 2 additions & 0 deletions include/frozen/bits/elsa_std.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
#include "elsa.h"
#include "hash_string.h"

#ifndef FROZEN_STD_MODULE
#ifdef FROZEN_LETITGO_HAS_STRING_VIEW
#include <string_view>
#endif
#include <string>
#endif

namespace frozen {

Expand Down
4 changes: 4 additions & 0 deletions include/frozen/bits/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@

#if defined(FROZEN_NO_EXCEPTIONS) || (defined(_MSC_VER) && !defined(_CPPUNWIND)) || (!defined(_MSC_VER) && !defined(__cpp_exceptions))

#ifndef FROZEN_STD_MODULE
#include <cstdlib>
#endif
#define FROZEN_THROW_OR_ABORT(_) std::abort()

#else

#ifndef FROZEN_STD_MODULE
#include <stdexcept>
#endif
#define FROZEN_THROW_OR_ABORT(err) throw err


Expand Down
4 changes: 3 additions & 1 deletion include/frozen/bits/hash_string.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#ifndef FROZEN_LETITGO_BITS_HASH_STRING_H
#define FROZEN_LETITGO_BITS_HASH_STRING_H

#ifndef FROZEN_STD_MODULE
#include <cstddef>
#endif

namespace frozen {

Expand All @@ -25,4 +27,4 @@ constexpr std::size_t hash_string(const String& value, std::size_t seed) {

} // namespace frozen

#endif // FROZEN_LETITGO_BITS_HASH_STRING_H
#endif // FROZEN_LETITGO_BITS_HASH_STRING_H
2 changes: 2 additions & 0 deletions include/frozen/bits/mpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
#ifndef FROZEN_LETITGO_BITS_MPL_H
#define FROZEN_LETITGO_BITS_MPL_H

#ifndef FROZEN_STD_MODULE
#include <utility>
#endif

namespace frozen {

Expand Down
2 changes: 2 additions & 0 deletions include/frozen/bits/pmh.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
#include "frozen/bits/algorithms.h"
#include "frozen/bits/basic_types.h"

#ifndef FROZEN_STD_MODULE
#include <array>
#include <cstddef>
#include <cstdint>
#include <limits>
#endif

namespace frozen {

Expand Down
2 changes: 2 additions & 0 deletions include/frozen/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
#include "frozen/bits/mpl.h"
#include "frozen/bits/version.h"

#ifndef FROZEN_STD_MODULE
#include <iterator>
#include <utility>
#endif

namespace frozen {

Expand Down
2 changes: 2 additions & 0 deletions include/frozen/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
#include "frozen/bits/algorithms.h"
#include "frozen/bits/version.h"

#ifndef FROZEN_STD_MODULE
#include <cstdint>
#include <type_traits>
#endif

namespace frozen {
template <class UIntType, UIntType a, UIntType c, UIntType m>
Expand Down
2 changes: 2 additions & 0 deletions include/frozen/set.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
#include "frozen/bits/version.h"
#include "frozen/bits/defines.h"

#ifndef FROZEN_STD_MODULE
#include <iterator>
#include <utility>
#endif

namespace frozen {

Expand Down
Loading