Skip to content

Commit ace4295

Browse files
committed
chore: Enable C++23 and abbreviations
It's been a few weeks and no opposition surfaced. This change allows new code to be written faster and less cluttered.
1 parent 1c8503f commit ace4295

File tree

6 files changed

+25
-19
lines changed

6 files changed

+25
-19
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.14)
33
project("tts.cpp" C CXX)
44
include(CheckIncludeFileCXX)
55

6-
set(CMAKE_CXX_STANDARD 20)
6+
set(CMAKE_CXX_STANDARD 23)
77
set(CMAKE_CXX_STANDARD_REQUIRED ON)
88
set(CMAKE_CXX_EXTENSIONS OFF)
99

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Additional Model support will initially be added based on open source model perf
4545
#### Requirements:
4646

4747
* Local GGUF format model file (see [py-gguf](./py-ggufs/README.md) for information on how to convert the hugging face models to GGUF).
48-
* C++17 and C17
48+
* C++23 and C11
4949
* XCode Command Line Tools (via `xcode-select --install`) should suffice for OS X
5050
* CMake (>=3.14)
5151
* GGML pulled locally

include/common.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
#ifndef common_h
2-
#define common_h
1+
#pragma once
32

4-
#include <cstdint>
5-
#include <string>
63
#include <map>
7-
#include <vector>
4+
#include "imports.h"
85

96
// Using this simple struct as opposed to a common std::vector allows us to return the cpu buffer
107
// pointer directly rather than copying the contents of the buffer to a predefined std::vector.
@@ -57,5 +54,3 @@ struct tts_runner {
5754
void init_build(std::vector<uint8_t>* buf_compute_meta);
5855
void free_build();
5956
};
60-
61-
#endif

include/imports.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
3+
#include <algorithm>
4+
#include <cstdint>
5+
#include <memory>
6+
#include <string_view>
7+
#include <ranges>
8+
#include <vector>
9+
10+
using namespace std;
11+
using namespace std::string_view_literals;
12+
typedef std::string_view sv;
13+
typedef const char * str;
14+
15+
#define TTS_ABORT(...) tts_abort(__FILE__, __LINE__, __VA_ARGS__)
16+
#define TTS_ASSERT(x) if (!(x)) TTS_ABORT("TTS_ASSERT(%s) failed", #x)
17+
[[noreturn]] void tts_abort(const char * file, int line, const char * fmt, ...);

src/util.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <algorithm>
44
#include <cstdio>
5+
#include <cstring>
56
#include <stdarg.h>
67
#ifdef __APPLE__
78
#include <sys/sysctl.h>

src/util.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22
#define util_h
33

44
#include <functional>
5-
#include <math.h>
5+
#include <cmath>
66
#include <random>
7-
#include <stdio.h>
8-
#include <string>
9-
#include <cstring>
10-
#include <vector>
7+
#include <cstdio>
118
#include <stdint.h>
129
#include <sys/types.h>
1310
#include "ggml-metal.h"
@@ -17,9 +14,7 @@
1714
#include "ggml.h"
1815
#include "ggml-impl.h"
1916
#include "ggml-cpp.h"
20-
21-
#define TTS_ABORT(...) tts_abort(__FILE__, __LINE__, __VA_ARGS__)
22-
#define TTS_ASSERT(x) if (!(x)) TTS_ABORT("TTS_ASSERT(%s) failed", #x)
17+
#include "imports.h"
2318

2419
struct model_tensor_meta {
2520
uint32_t n_tensors = 0;
@@ -60,6 +55,4 @@ std::vector<std::string> split(std::string target, const char split_on, bool inc
6055
std::string strip(std::string target, std::string vals = " ");
6156
std::string replace_any(std::string target, std::string to_replace, std::string replacement);
6257

63-
[[noreturn]] void tts_abort(const char * file, int line, const char * fmt, ...);
64-
6558
#endif

0 commit comments

Comments
 (0)