Skip to content

Commit

Permalink
v2024.05 (#128)
Browse files Browse the repository at this point in the history
* Add tuple_for_each

* Use maybe_const

* Add views::zip, ranges::zip_view

* Update zip_view.hpp

* Update zip_view.hpp

* Add to_array

* Create three_way_comparable.hpp

* Fix zip_view

* Add zip_transfrom_view

* Add find_last

* Update zip_transform_view.hpp

* Add ranges::find_end

* Add ranges:: find_first_of

* Update algorithm_test.cpp

* Create debug_assert.hpp

* Update doxy

* Create ignore_dumb_diagnostics_pop.hpp

* Create ignore_dumb_diagnostics_push.hpp

* Update tuple_for_each.hpp

* Update tuple_transform.hpp

* Fix iter_move, iter_swap

* Update iterator_test.cpp

* Fix error

* Update transform_view.hpp

* Fix pragma warning

* Update join_with_view.hpp

* Update transform_view.hpp

* Update transform_view.hpp

* Update fold_left.hpp

* Update non_propagating_cache.hpp

* Update indirectly_swappable.hpp

* Add ranges::make_heap

* Add pop_heap

* Add ranges::sort_heap

* Update debug_assert.hpp

* Update equal_to.hpp

* Update cxx20_rel_ops.hpp

* Add ranges::sort

* Add saturate_cast

* Add ranges::contains, ranges::contains_subrange

* Update zip_view.hpp

* Update saturate_cast.hpp

* Update saturate_cast.hpp

* Update counted_iterator.hpp

* Update take_view.hpp

* Add missing comparison operators

* Fix ssize

* Update from_range.hpp

* Update string_view.hpp

* Update emscripten from 3.1.34 -> 3.1.57

* Update from_range.hpp

* Update from_range.hpp

* Update expected.hpp

* Add logging with custom tag

* Add cmp_xxx

* Add is_character

* Update cmp.hpp

* Add in_range

* Add ranges::clamp

* Update cmp.hpp

* Update in_range.hpp

* Update filter_view.hpp

* Fix filter_view::iterator::iterator_category

* Fix elements_view::iterator::iterator_category

* Fix join_view::iterator::iterator_category

* Add tuple_for_each_index

* fix cmp_xxx

* Add copy_template

* Add sequence_for_each

* Add bind

* Add test

* Update string_view.hpp

* Update docs

* Update version_history.txt

* Update version_history.txt

* Add missing groups

* Update mainpage.txt

* Update header.html
  • Loading branch information
lackhole authored May 26, 2024
1 parent d4dbbdd commit 60546c2
Show file tree
Hide file tree
Showing 132 changed files with 4,031 additions and 320 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

env:
BUILD_TYPE: Release
EMSDK_VERSION: 3.1.34
EMSDK_VERSION: 3.1.57

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ PROJECT_NAME = VCCC
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 1.3.1
PROJECT_NUMBER = 2024.05

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
4 changes: 2 additions & 2 deletions docs/doxygen-awesome-css/doxygen-custom/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
<meta name="viewport" content="width=device-width, initial-scale=1"/>

<!-- BEGIN opengraph metadata -->
<meta property="og:title" content="Doxygen Awesome" />
<meta property="og:title" content="VCCC Document" />
<meta property="og:image" content="https://repository-images.githubusercontent.com/348492097/4f16df80-88fb-11eb-9d31-4015ff22c452" />
<meta property="og:description" content="Custom CSS theme for doxygen html-documentation with lots of customization parameters." />
<meta property="og:url" content="https://jothepro.github.io/doxygen-awesome-css/" />
<!-- END opengraph metadata -->

<!-- BEGIN twitter metadata -->
<meta name="twitter:image:src" content="https://repository-images.githubusercontent.com/348492097/4f16df80-88fb-11eb-9d31-4015ff22c452" />
<meta name="twitter:title" content="Doxygen Awesome" />
<meta name="twitter:title" content="VCCC Document" />
<meta name="twitter:description" content="Custom CSS theme for doxygen html-documentation with lots of customization parameters." />
<!-- END twitter metadata -->

Expand Down
10 changes: 8 additions & 2 deletions docs/mainpage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,26 @@

\section Overview
VCCC is a cross-platform header-only library consisting of several modules written C++14. <br>
It provides various algorithms, implementing C++17 and C++20 feature in C++14.
It provides various algorithms, implementing C++17 ... C++26 feature in C++14.

\section compiler_support Compiler Support
- GCC 6.0 or above
- Clang 8.0 or above
- MSVC 15.0 or above
- Emscripten 2.0.14 or above (below versions are not tested)
- Emscripten 3.1.57 or above (tested 2.0.14 ~)

\section Libraries
- \subpage algorithm. \copybrief algorithm
- \subpage array. \copybrief array
- \subpage compare. \copybrief compare
- \subpage concepts. \copybrief concepts
- \subpage expected. \copybrief expected
- \subpage functional. \copybrief functional
- \subpage iterator. \copybrief iterator
- \subpage literal. \copybrief literal
- \subpage log. \copybrief log
- \subpage math. \copybrief math
- \subpage memory. \copybrief memory
- \subpage numeric. \copybrief numeric
- \subpage optional. \copybrief optional
- \subpage random. \copybrief random
Expand All @@ -31,6 +36,7 @@ It provides various algorithms, implementing C++17 and C++20 feature in C++14.
- \subpage type_support. \copybrief type_support
- \subpage type_traits. \copybrief type_traits
- \subpage utility. \copybrief utility
- \subpage variant. \copybrief variant

\section third_party_libraries Third Party Libraries
\subsection boost_predef Boost.Predef
Expand Down
105 changes: 105 additions & 0 deletions docs/pages/version_history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,111 @@

\tableofcontents

\section version_2024_05 v2024.05
- \subpage log
- Add \ref Log_t::operator() for custom priority and tag

- \subpage algorithm
- Add \ref ranges::clamp
- Add \ref ranges::contains
- Add \ref ranges::constains_subrange
- Add \ref ranges::find_end
- Add \ref ranges::find_first_of
- Add \ref ranges::find_last
- Add \ref ranges::make_heap
- Add \ref ranges::pop_heap
- Add \ref ranges::sort
- Add \ref ranges::sort_heap
- Fix \ref ranges::fold_left

- \subpage array
- Add \ref to_array

- \subpage compare
- Add \ref unstable_three_way_comparable

- \subpage concepts
- Fix lookup of \ref ranges::swap

- \subpage expected
- Fix \ref expected::operator*()

- \subpage functional
- Add \ref bind_back
- Add \ref bind_front
- Fix \ref ranges::equal_to

- \subpage iterator
- Add \ref common_iterator::iter_move
- Add \ref common_iterator::iter_swap
- Add \ref counted_iterator::iter_move
- Add \ref counted_iterator::iter_swap
- Add \ref move_iterator
- Add \ref reverse_iterator
- Fix lookup of \ref ranges::advance
- Fix comparison with \ref counted_iterator and \ref default_sentinel_t
- Fix \ref indirectly_swappable
- Fix \ref ranges::iter_move
- Fix \ref ranges::iter_swap
- Fix lookup of \ref ranges::next
- Fix lookup of \ref ranges::prev

- \subpage numeric
- Add \ref saturate_cast

- \subpage ranges
- Add \ref ranges::cartesian_product_view::iter_move
- Add \ref ranges::cartesian_product_view::iter_swap
- Add \ref ranges::enumerate_view::iter_move
- Add \ref ranges::enumerate_view::iter_swap
- Add \ref ranges::filter_view::iter_move
- Add \ref ranges::filter_view::iter_swap
- Add \ref ranges::join_view::iter_move
- Add \ref ranges::join_view::iter_swap
- Add \ref ranges::join_with_view::iter_move
- Add \ref ranges::join_with_view::iter_swap
- Add \ref ranges::transform_view::iter_move
- Add \ref ranges::zip_view, \ref views::zip
- Add \ref ranges::zip_transform_view, \ref views::zip_transform
- Fix lookup of \ref ranges::begin
- Fix lookup of \ref ranges::cbegin
- Fix lookup of \ref ranges::cdata
- Fix lookup of \ref ranges::cend
- Fix lookup of \ref ranges::crbegin
- Fix lookup of \ref ranges::crend
- Fix lookup of \ref ranges::data
- Fix lookup of \ref ranges::distance
- Fix lookup of \ref ranges::empty
- Fix lookup of \ref ranges::end
- Fix lookup of \ref ranges::from_range
- Fix \ref ranges::non_propagating_cache::non_propagating_cache()
- Fix lookup of \ref ranges::rbegin
- Fix lookup of \ref ranges::rend
- Fix lookup of \ref ranges::size
- Fix lookup of \ref ranges::ssize
- Fix initialization order of \ref ranges::subrange
- Fix lookup of \ref views::all
- Fix lookup of \ref views::single
- Fix comparison with \ref take_view::sentinel and \ref counted_iterator
- Fix comparison with \ref transform_view::iterator and \ref transform_view::sentinel

- \subpage tuple
- Add \ref tuple_for_each, \ref tuple_for_each_index
- Fix \ref tuple_transform

- \subpage type_traits
- Add \ref copy_template, \ref copy_template_t
- Fix \ref ssize

- \subpage utility
- Add \ref cmp_equal, \ref cmp_not_equal, \ref cmp_less, \ref cmp_greater, \ref cmp_less_equal, \ref cmp_greater_equal
- Add \ref in_range
- Add \ref sequence_for_each

- Others
- Remove false diagnostic messages
- Update emscripten from 3.1.34 -> 3.1.57

\section version_1_3_1 v1.3.1
- \subpage algorithm
- Add \ref vccc::ranges::copy
Expand Down
8 changes: 6 additions & 2 deletions include/log/include/vccc/__log/detail/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# include <android/log.h>
#
# define VCCC_LOG_PRINTER(buf, tag, fmt, ...) __android_log_print(buf, tag, fmt, __VA_ARGS__)
#
# // https://developer.android.com/ndk/reference/group/logging
# define VCCC_LOG_BUFFER_DEBUG ANDROID_LOG_DEBUG
# define VCCC_LOG_BUFFER_INFO ANDROID_LOG_DEBUG
# define VCCC_LOG_BUFFER_WARN ANDROID_LOG_ERROR
Expand All @@ -22,7 +24,9 @@
# include "TargetConditionals.h"
# include <syslog.h>
#
# define VCCC_LOG_PRINTER(buf, tag, fmt, ...) syslog(buf, tag fmt, __VA_ARGS__)
# define VCCC_LOG_PRINTER(buf, tag, fmt, ...) syslog(buf, "%s" fmt, tag, __VA_ARGS__)
#
# // https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/syslog.3.html
# define VCCC_LOG_BUFFER_DEBUG LOG_DEBUG
# define VCCC_LOG_BUFFER_INFO LOG_DEBUG
# define VCCC_LOG_BUFFER_WARN LOG_ERR
Expand All @@ -31,7 +35,7 @@
# else // for wasm, Windows, MacOS
# include <cstdio>
#
# define VCCC_LOG_PRINTER(buf, tag, fmt, ...) VCCC_LOG_EXPAND(std::fprintf(buf, tag fmt "\n", __VA_ARGS__))
# define VCCC_LOG_PRINTER(buf, tag, fmt, ...) VCCC_LOG_EXPAND(std::fprintf(buf, "%s" fmt "\n", tag, __VA_ARGS__))
# define VCCC_LOG_BUFFER_DEBUG stdout
# define VCCC_LOG_BUFFER_INFO stdout
# define VCCC_LOG_BUFFER_WARN stderr
Expand Down
11 changes: 5 additions & 6 deletions include/log/include/vccc/__log/detail/log_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
# define VCCC_LOG_DETAIL_LOG_IMPL_H_
#
# include "vccc/__log/detail/buffer.h"
# include "vccc/__log/detail/tag.h"
#
# ifdef NDEBUG
# define LOGD_IMPL(...)
# define LOGD_IMPL(tag, fmt, ...)
# else
# define LOGD_IMPL(...) VCCC_LOG_EXPAND(VCCC_LOG_PRINTER(VCCC_LOG_BUFFER_DEBUG, VCCC_LOG_TAG_DEBUG, __VA_ARGS__))
# define LOGD_IMPL(tag, fmt, ...) VCCC_LOG_EXPAND(VCCC_LOG_PRINTER(VCCC_LOG_BUFFER_DEBUG, tag, fmt, __VA_ARGS__))
# endif
#
# define LOGI_IMPL(...) VCCC_LOG_EXPAND(VCCC_LOG_PRINTER(VCCC_LOG_BUFFER_INFO, VCCC_LOG_TAG_INFO, __VA_ARGS__))
# define LOGW_IMPL(...) VCCC_LOG_EXPAND(VCCC_LOG_PRINTER(VCCC_LOG_BUFFER_WARN, VCCC_LOG_TAG_WARN, __VA_ARGS__))
# define LOGE_IMPL(...) VCCC_LOG_EXPAND(VCCC_LOG_PRINTER(VCCC_LOG_BUFFER_ERROR, VCCC_LOG_TAG_ERROR, __VA_ARGS__))
# define LOGI_IMPL(tag, fmt, ...) VCCC_LOG_EXPAND(VCCC_LOG_PRINTER(VCCC_LOG_BUFFER_INFO, tag, fmt, __VA_ARGS__))
# define LOGW_IMPL(tag, fmt, ...) VCCC_LOG_EXPAND(VCCC_LOG_PRINTER(VCCC_LOG_BUFFER_WARN, tag, fmt, __VA_ARGS__))
# define LOGE_IMPL(tag, fmt, ...) VCCC_LOG_EXPAND(VCCC_LOG_PRINTER(VCCC_LOG_BUFFER_ERROR, tag, fmt, __VA_ARGS__))
#
# endif //VCCC_LOG_DETAIL_LOG_IMPL_H_
59 changes: 50 additions & 9 deletions include/log/include/vccc/__log/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
# ifndef VCCC_LOG_LOG_HPP
# define VCCC_LOG_LOG_HPP
#
# include "vccc/__core/inline_or_static.hpp"
# include "vccc/__log/detail/log_impl.h"
# include "vccc/__log/detail/tag.h"
# include "vccc/__log/stream_wrapper.hpp"


Expand Down Expand Up @@ -51,19 +53,58 @@ if ostringstream& operator << is overloaded for user-defined types, it can be pr
*/
class Logger {
public:
enum Priority {
kDebug,
kInfo,
kWarn,
kError,
};

using stream_type = StreamWrapper;
using string_type = std::string;

constexpr Logger() = default;

/** @brief Log output as debug */
template<typename ...Args> void d(const Args&... args) const { d_(to_string(args...)); }
template<typename ...Args> void d(const Args&... args) const {
d_(VCCC_LOG_TAG_DEBUG, to_string(args...));
}

/** @brief Informational log */
template<typename ...Args> void i(const Args&... args) const { i_(to_string(args...)); }
template<typename ...Args> void i(const Args&... args) const {
i_(VCCC_LOG_TAG_INFO, to_string(args...));
}

/** @brief Warning log */
template<typename ...Args> void w(const Args&... args) const { w_(to_string(args...)); }
template<typename ...Args> void w(const Args&... args) const {
w_(VCCC_LOG_TAG_WARN, to_string(args...));
}

/** @brief Error log */
template<typename ...Args> void e(const Args&... args) const { e_(to_string(args...)); }
template<typename ...Args> void e(const Args&... args) const {
e_(VCCC_LOG_TAG_ERROR, to_string(args...));
}

template<typename... Args>
void operator()(Priority priority, const char* tag, const Args&... args) const {
switch (priority) {
case kDebug:
this->d_(tag, to_string(args...));
return;

case kInfo:
this->i_(tag, to_string(args...));
return;

case kWarn:
this->w_(tag, to_string(args...));
return;

case kError:
this->e_(tag, to_string(args...));
return;
}
}

/** @brief Return logged value as std::string
*
Expand All @@ -86,16 +127,16 @@ class Logger {
}

private:
template<typename ...Args> void d_(const std::string& str) const { LOGD_IMPL("%s", str.c_str()); }
template<typename ...Args> void i_(const std::string& str) const { LOGI_IMPL("%s", str.c_str()); }
template<typename ...Args> void w_(const std::string& str) const { LOGW_IMPL("%s", str.c_str()); }
template<typename ...Args> void e_(const std::string& str) const { LOGE_IMPL("%s", str.c_str()); }
template<typename ...Args> void d_(const char* tag, const std::string& str) const { LOGD_IMPL(tag, "%s", str.c_str()); }
template<typename ...Args> void i_(const char* tag, const std::string& str) const { LOGI_IMPL(tag, "%s", str.c_str()); }
template<typename ...Args> void w_(const char* tag, const std::string& str) const { LOGW_IMPL(tag, "%s", str.c_str()); }
template<typename ...Args> void e_(const char* tag, const std::string& str) const { LOGE_IMPL(tag, "%s", str.c_str()); }
};

/**
@brief Global vccc::Logger instance for syntax sugar
*/
constexpr Logger Log;
constexpr VCCC_INLINE_OR_STATIC Logger Log;

/// @defgroup log_log_macro__macro__Logging_macros LOGD, LOGI, LOGID, LOGW, LOGWD, LOGE, LOGED
/// @{
Expand Down
66 changes: 66 additions & 0 deletions include/vccc/__algorithm/ranges/clamp.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// Created by YongGyu Lee on 5/8/24.
//

#ifndef VCCC_ALGORITHM_RANGES_CLAMP_HPP_
#define VCCC_ALGORITHM_RANGES_CLAMP_HPP_

#include <utility>

#include "vccc/__core/inline_or_static.hpp"
#include "vccc/__functional/identity.hpp"
#include "vccc/__functional/invoke.hpp"
#include "vccc/__functional/less.hpp"
#include "vccc/__iterator/indirect_strict_weak_order.hpp"
#include "vccc/__iterator/projected.hpp"
#include "vccc/__type_traits/conjunction.hpp"

namespace vccc {
namespace ranges {
namespace detail {

struct clamp_niebloid {
template<typename T, typename Proj = identity, typename Comp = ranges::less, std::enable_if_t<conjunction<
projectable<const T*, Proj>,
indirect_strict_weak_order<Comp, projected<const T*, Proj>>
>::value, int> = 0>
constexpr const T& operator()(const T& v, const T& lo, const T& hi, Comp comp = {}, Proj proj = {}) const {
auto&& pv = vccc::invoke(proj, v);

if (vccc::invoke(comp, std::forward<decltype(pv)>(pv), vccc::invoke(proj, lo)))
return lo;

if (vccc::invoke(comp, vccc::invoke(proj, hi), std::forward<decltype(pv)>(pv)))
return hi;

return v;
}
};

} // namespace detail

/// @addtogroup algorithm
/// @{

/**
@brief clamps a value between a pair of boundary values
If `v` compares less than `lo`, returns `lo`; otherwise if `hi` compares less than `v`, returns `hi`; otherwise returns `v`.
The behavior is undefined if `lo` is greater than `hi`.
<H1>Complexity</H1>
At most two comparisons and three applications of the projection.
@sa [std::ranges::clamp](https://en.cppreference.com/w/cpp/algorithm/ranges/clamp)
@sa [std::clamp](https://en.cppreference.com/w/cpp/algorithm/clamp)
@sa vccc::clamp
*/
VCCC_INLINE_OR_STATIC constexpr detail::clamp_niebloid clamp{};

/// @}

} // namespace ranges
} // namespace vccc

#endif // VCCC_ALGORITHM_RANGES_CLAMP_HPP_
Loading

0 comments on commit 60546c2

Please sign in to comment.