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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"__split_buffer": "cpp",
"__tree": "cpp",
"queue": "cpp",
"stack": "cpp"
"stack": "cpp",
"ranges": "cpp"
},
}
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@ All notable changes to this project will be documented in this file.

## Next Release

### Enum

- introduce `MSTD_ENUM_BITFLAG` for bitwise operations on enums

### String

- introduce new string library
- add `join` function to concatenate string_view like ranges with a delimiter

### Type Traits

- add concept `joinable_range`

<!-- insertion marker -->
## [0.0.3](https://github.com/repo/owner/releases/tag/0.0.3) - 2026-02-08

Expand Down
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.20)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

project(mstd
VERSION 0.1.0
LANGUAGES CXX
Expand All @@ -19,7 +22,7 @@ target_include_directories(mstd

target_compile_features(mstd
INTERFACE
cxx_std_20
cxx_std_23
)

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
Expand Down
28 changes: 28 additions & 0 deletions include/mstd/string.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*****************************************************************************
<GPL_HEADER>

mstd library
Copyright (C) 2025-now Jakob Gamper

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

<GPL_HEADER>
******************************************************************************/

#ifndef __MSTD__STRING_HPP__
#define __MSTD__STRING_HPP__

#include "string/join.hpp" // IWYU pragma: export

#endif // __MSTD__STRING_HPP__
64 changes: 64 additions & 0 deletions include/mstd/string/join.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*****************************************************************************
<GPL_HEADER>

mstd library
Copyright (C) 2025-now Jakob Gamper

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

<GPL_HEADER>
******************************************************************************/

#ifndef __MSTD__STRING__JOIN_HPP__
#define __MSTD__STRING__JOIN_HPP__

#include <ranges>
#include <string>

#include "mstd/type_traits/ranges_traits.hpp"

namespace mstd
{
/**
* @brief Join a range of strings into a single string with a delimiter
*
* @tparam R
* @param r
* @param delim
* @return std::string
*/
template <joinable_range R>
std::string join(R&& r, std::string_view delim)
{
auto joined = std::ranges::views::join_with(std::forward<R>(r), delim);

return {joined.begin(), joined.end()};
}

/**
* @brief overload of join that uses an empty string as delimiter
*
* @tparam R
* @param r
* @return std::string
*/
template <joinable_range R>
std::string join(R&& r)
{
return join(std::forward<R>(r), "");
}

} // namespace mstd

#endif // __MSTD__STRING__JOIN_HPP__
1 change: 1 addition & 0 deletions include/mstd/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "type_traits/math_traits.hpp" // IWYU pragma: export
#include "type_traits/pack_traits.hpp" // IWYU pragma: export
#include "type_traits/quantity_traits.hpp" // IWYU pragma: export
#include "type_traits/ranges_traits.hpp" // IWYU pragma: export
#include "type_traits/ratio_traits.hpp" // IWYU pragma: export

#endif // __MSTD__TYPE_TRAITS_HPP__
43 changes: 43 additions & 0 deletions include/mstd/type_traits/ranges_traits.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*****************************************************************************
<GPL_HEADER>

mstd library
Copyright (C) 2025-now Jakob Gamper

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

<GPL_HEADER>
******************************************************************************/

#ifndef __MSTD__TYPE_TRAITS__RANGES_TRAITS_HPP__
#define __MSTD__TYPE_TRAITS__RANGES_TRAITS_HPP__

#include <ranges>

namespace mstd
{
/**
* @brief concept for ranges that can be joined into a string with a
* delimiter
*
* @tparam Range
*/
template <typename Range>
concept joinable_range = std::ranges::input_range<Range> &&
std::convertible_to<
std::ranges::range_reference_t<Range>,
std::string_view>;
} // namespace mstd

#endif // __MSTD__TYPE_TRAITS__RANGES_TRAITS_HPP__