9 Commits cd4bc87342 ... caf85c26b8

Author SHA1 Message Date
  __vic caf85c26b8 Merge branch 'generic' into posix 1 month ago
  __vic f1e2bb58b0 Merge branch 'iso' into generic 1 month ago
  __vic d844f1d068 logger: std::format support added 1 month ago
  __vic f68a78d3d1 readonly_cstring: duplicated code removed 2 months ago
  __vic 301fee1ad9 Protection from isascii() macro added 2 months ago
  __vic 51356a1302 Logical operator traits added 2 months ago
  __vic 18e2f5bd64 Parens for __VIC_STD_MOVE(v) parameter 6 months ago
  __vic 1a795cbf7c __VIC_SWAP_HEADER fix 6 months ago
  __vic 362f7fb486 __VIC_INLINE_CONSTEXPR_VAR added 6 months ago

+ 16 - 0
ChangeLog

@@ -4,6 +4,22 @@ Legend:
     * Changes
     ! Important
 
+2024-02-05  __vic
+    + logger: std::format support
+
+2024-02-27  __vic
+    * ascii.h: protection from isascii() macro
+    * readonly_cstring: duplicated code removed
+
+2024-02-16  __vic
+    * type_traits.h:
+        + conditional
+        + conjunction, disjunction, negation
+
+2023-10-20  __vic
+    + __VIC_INLINE_CONSTEXPR_VAR
+    - __VIC_SWAP_HEADER definition was invalid
+
 2023-10-06  __vic
     + C++23 mode support
     * C++17 is used by default

+ 56 - 0
doc/en/logger.h.xml

@@ -77,6 +77,35 @@ public:
     void error(const std::string &msg);
     void fatal(const std::string &msg);
 #endif
+
+#if __cpp_lib_format >= 202106L // C++20 + P2508
+    template<class... Args>
+    void format(severity_t s,
+        std::format_string<Args...> fmt, Args&&... args);
+
+    template<class Arg1, class... Args>
+    void trace(
+        std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args);
+    template<class Arg1, class... Args>
+    void debug(
+        std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args);
+    template<class Arg1, class... Args>
+    void info(
+        std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args);
+    template<class Arg1, class... Args>
+    void notice(
+        std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args);
+    template<class Arg1, class... Args>
+    void warning(
+        std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args);
+    template<class Arg1, class... Args>
+    void error(
+        std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args);
+    template<class Arg1, class... Args>
+    void fatal(
+        std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args);
+#endif
+
     record trace();
     record debug();
     record info();
@@ -321,6 +350,33 @@ are formed.</p>
 </synopsis>
 
 <synopsis>
+<prototype><![CDATA[template<class... Args>
+void format(severity_t s,
+    std::format_string<Args...> fmt, Args&&... args)]]> <sign>C++20</sign></prototype>
+<p>Formats the message using the specified format string and arguments (like
+<tt>std::format</tt> does) then writes it with the specified severity.</p>
+</synopsis>
+
+<synopsis>
+<prototype><![CDATA[template<class Arg1, class... Args>
+void trace(std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args)]]> <sign>C++20</sign></prototype>
+<prototype><![CDATA[template<class Arg1, class... Args>
+void debug(std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args)]]> <sign>C++20</sign></prototype>
+<prototype><![CDATA[template<class Arg1, class... Args>
+void info(std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args)]]> <sign>C++20</sign></prototype>
+<prototype><![CDATA[template<class Arg1, class... Args>
+void notice(std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args)]]> <sign>C++20</sign></prototype>
+<prototype><![CDATA[template<class Arg1, class... Args>
+void warning(std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args)]]> <sign>C++20</sign></prototype>
+<prototype><![CDATA[template<class Arg1, class... Args>
+void error(std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args)]]> <sign>C++20</sign></prototype>
+<prototype><![CDATA[template<class Arg1, class... Args>
+void fatal(std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args)]]> <sign>C++20</sign></prototype>
+<p>Formats the message using the specified format string and arguments (like
+<tt>std::format</tt> does) then writes it with the corresponding severity.</p>
+</synopsis>
+
+<synopsis>
 <prototype>logger::record trace()</prototype>
 <prototype>logger::record debug()</prototype>
 <prototype>logger::record info()</prototype>

+ 4 - 2
doc/en/readonly_cstring.h.xml

@@ -22,8 +22,9 @@ public:
 
     readonly_cstring &operator=(const char *str);
     readonly_cstring &operator=(const readonly_cstring &str);
-    readonly_cstring &assign(const char *begin, const char *end);
+    readonly_cstring &assign(const char *str);
     readonly_cstring &assign(const char *chars, size_t n);
+    readonly_cstring &assign(const char *begin, const char *end);
 
     bool empty() const;
     const char *c_str() const;
@@ -103,14 +104,15 @@ for such purposes.</p>
 </synopsis>
 
 <synopsis>
-<prototype>readonly_cstring(const char *begin, const char *end)</prototype>
 <prototype>readonly_cstring(const char *chars, size_t n)</prototype>
+<prototype>readonly_cstring(const char *begin, const char *end)</prototype>
 <p>Creates a string from characters range.</p>
 </synopsis>
 
 <synopsis>
 <prototype>readonly_cstring &amp;operator=(const char *str)</prototype>
 <prototype>readonly_cstring &amp;operator=(const readonly_cstring &amp;str)</prototype>
+<prototype>readonly_cstring &amp;assign(const char *str)</prototype>
 <p>Assigns <tt>str</tt>.</p>
 </synopsis>
 

+ 54 - 0
doc/en/type_traits.h.xml

@@ -103,6 +103,44 @@ types" (see the Standard).</p>
 </chapter>
 
 
+<chapter xml:id="conjunction">
+<title><tt>conjunction</tt> <sign>C++11</sign></title>
+
+<code-block lang="C++"><![CDATA[
+template<class... B> struct conjunction;
+]]></code-block>
+
+<p>A predicate. The logical conjunction of the predicates <tt>B...</tt>.
+False iff one of the <tt>B...</tt> is false.</p>
+
+</chapter>
+
+
+<chapter xml:id="disjunction">
+<title><tt>disjunction</tt> <sign>C++11</sign></title>
+
+<code-block lang="C++"><![CDATA[
+template<class... B> struct disjunction;
+]]></code-block>
+
+<p>A predicate. The logical disjunction of the predicates <tt>B...</tt>.
+True iff one of the <tt>B...</tt> is true.</p>
+
+</chapter>
+
+
+<chapter xml:id="negation">
+<title><tt>negation</tt></title>
+
+<code-block lang="C++"><![CDATA[
+template<class B> struct negation;
+]]></code-block>
+
+<p>A predicate. The logical negation of the predicate <tt>B</tt>.</p>
+
+</chapter>
+
+
 <chapter xml:id="remove_const">
 <title><tt>remove_const</tt></title>
 
@@ -187,6 +225,22 @@ template<class T> using remove_pointer_t = typename remove_pointer<T>::type;
 </chapter>
 
 
+<chapter xml:id="conditional">
+<title><tt>conditional</tt></title>
+
+<code-block lang="C++"><![CDATA[
+template<bool Cond, class Then, class Else> struct conditional;
+
+template<bool Cond, class Then, class Else>
+using conditional_t = typename conditional<Cond, Then, Else>;
+]]></code-block>
+
+<p>A type transformer. Returns <tt>Then</tt> if <tt>Cond == true</tt>.
+<tt>Else</tt> is returned otherwise.</p>
+
+</chapter>
+
+
 <chapter xml:id="enable_if">
 <title><tt>enable_if</tt>, <tt>disable_if</tt></title>
 

+ 57 - 0
doc/ru/logger.h.xml

@@ -77,6 +77,35 @@ public:
     void error(const std::string &msg);
     void fatal(const std::string &msg);
 #endif
+
+#if __cpp_lib_format >= 202106L // C++20 + P2508
+    template<class... Args>
+    void format(severity_t s,
+        std::format_string<Args...> fmt, Args&&... args);
+
+    template<class Arg1, class... Args>
+    void trace(
+        std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args);
+    template<class Arg1, class... Args>
+    void debug(
+        std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args);
+    template<class Arg1, class... Args>
+    void info(
+        std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args);
+    template<class Arg1, class... Args>
+    void notice(
+        std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args);
+    template<class Arg1, class... Args>
+    void warning(
+        std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args);
+    template<class Arg1, class... Args>
+    void error(
+        std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args);
+    template<class Arg1, class... Args>
+    void fatal(
+        std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args);
+#endif
+
     record trace();
     record debug();
     record info();
@@ -323,6 +352,34 @@ C++98. Начиная с C++11 это просто синоним <tt>severity</
 </synopsis>
 
 <synopsis>
+<prototype><![CDATA[template<class... Args>
+void format(severity_t s,
+    std::format_string<Args...> fmt, Args&&... args)]]> <sign>C++20</sign></prototype>
+<p>Форматирует сообщение используя указанную строку формата и аргументы
+(подобно <tt>std::format</tt>), затем выводит его с заданным приоритетом.</p>
+</synopsis>
+
+<synopsis>
+<prototype><![CDATA[template<class Arg1, class... Args>
+void trace(std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args)]]> <sign>C++20</sign></prototype>
+<prototype><![CDATA[template<class Arg1, class... Args>
+void debug(std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args)]]> <sign>C++20</sign></prototype>
+<prototype><![CDATA[template<class Arg1, class... Args>
+void info(std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args)]]> <sign>C++20</sign></prototype>
+<prototype><![CDATA[template<class Arg1, class... Args>
+void notice(std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args)]]> <sign>C++20</sign></prototype>
+<prototype><![CDATA[template<class Arg1, class... Args>
+void warning(std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args)]]> <sign>C++20</sign></prototype>
+<prototype><![CDATA[template<class Arg1, class... Args>
+void error(std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args)]]> <sign>C++20</sign></prototype>
+<prototype><![CDATA[template<class Arg1, class... Args>
+void fatal(std::format_string<Arg1,Args...> fmt, Arg1 &&arg1, Args&&... args)]]> <sign>C++20</sign></prototype>
+<p>Форматирует сообщение используя указанную строку формата и аргументы
+(подобно <tt>std::format</tt>), затем выводит его с соответствующим
+приоритетом.</p>
+</synopsis>
+
+<synopsis>
 <prototype>logger::record trace()</prototype>
 <prototype>logger::record debug()</prototype>
 <prototype>logger::record info()</prototype>

+ 4 - 2
doc/ru/readonly_cstring.h.xml

@@ -22,8 +22,9 @@ public:
 
     readonly_cstring &operator=(const char *str);
     readonly_cstring &operator=(const readonly_cstring &str);
-    readonly_cstring &assign(const char *begin, const char *end);
+    readonly_cstring &assign(const char *str);
     readonly_cstring &assign(const char *chars, size_t n);
+    readonly_cstring &assign(const char *begin, const char *end);
 
     bool empty() const;
     const char *c_str() const;
@@ -105,14 +106,15 @@ void swap(readonly_cstring &s1, readonly_cstring &s2) noexcept;
 </synopsis>
 
 <synopsis>
-<prototype>readonly_cstring(const char *begin, const char *end)</prototype>
 <prototype>readonly_cstring(const char *chars, size_t n)</prototype>
+<prototype>readonly_cstring(const char *begin, const char *end)</prototype>
 <p>Создаёт строку из диапазона символов.</p>
 </synopsis>
 
 <synopsis>
 <prototype>readonly_cstring &amp;operator=(const char *str)</prototype>
 <prototype>readonly_cstring &amp;operator=(const readonly_cstring &amp;str)</prototype>
+<prototype>readonly_cstring &amp;assign(const char *str)</prototype>
 <p>Присваивает <tt>str</tt>.</p>
 </synopsis>
 

+ 54 - 0
doc/ru/type_traits.h.xml

@@ -104,6 +104,44 @@ template<class T> struct is_unsigned_integer;
 </chapter>
 
 
+<chapter xml:id="conjunction">
+<title><tt>conjunction</tt> <sign>C++11</sign></title>
+
+<code-block lang="C++"><![CDATA[
+template<class... B> struct conjunction;
+]]></code-block>
+
+<p>Предикат. Конъюнкция предикатов <tt>B...</tt>. Ложен тогда и только тогда,
+когда ложен один из <tt>B...</tt>.</p>
+
+</chapter>
+
+
+<chapter xml:id="disjunction">
+<title><tt>disjunction</tt> <sign>C++11</sign></title>
+
+<code-block lang="C++"><![CDATA[
+template<class... B> struct disjunction;
+]]></code-block>
+
+<p>Предикат. Дизъюнкция предикатов <tt>B...</tt>. Истинен тогда и только тогда,
+когда истинен один из <tt>B...</tt>.</p>
+
+</chapter>
+
+
+<chapter xml:id="negation">
+<title><tt>negation</tt></title>
+
+<code-block lang="C++"><![CDATA[
+template<class B> struct negation;
+]]></code-block>
+
+<p>Предикат. Логическое отрицание предиката <tt>B</tt>.</p>
+
+</chapter>
+
+
 <chapter xml:id="remove_const">
 <title><tt>remove_const</tt></title>
 
@@ -191,6 +229,22 @@ template<class T> using remove_pointer_t = typename remove_pointer<T>::type;
 </chapter>
 
 
+<chapter xml:id="conditional">
+<title><tt>conditional</tt></title>
+
+<code-block lang="C++"><![CDATA[
+template<bool Cond, class Then, class Else> struct conditional;
+
+template<bool Cond, class Then, class Else>
+using conditional_t = typename conditional<Cond, Then, Else>;
+]]></code-block>
+
+<p>Преобразователь типа. Возвращает <tt>Then</tt>, если <tt>Cond == true</tt>.
+В противном случае - <tt>Else</tt>.</p>
+
+</chapter>
+
+
 <chapter xml:id="enable_if">
 <title><tt>enable_if</tt>, <tt>disable_if</tt></title>
 

+ 10 - 4
include/__vic/_cfg.h

@@ -223,7 +223,7 @@
 #endif
 
 //////////////////////////////////////////////////////////////////////////////
-// C++14/C++11/C++98 compatibility macros
+// C++23/20/17/14/11/98 compatibility macros
 //////////////////////////////////////////////////////////////////////////////
 #if __cplusplus < 201103L && !defined(__VIC_NO_NOEXCEPT_DEF)
 #define noexcept throw()
@@ -239,13 +239,13 @@
 
 #if __cplusplus >= 201103L // C++11
 #   define __VIC_THROWS noexcept(false)
-#   define __VIC_SWAP_HEADER <algorithm>
+#   define __VIC_SWAP_HEADER <utility>
 #   define __VIC_SCOPED_ENUM_UT_BEGIN(name,type) enum class name : type
 #   define __VIC_SCOPED_ENUM_BEGIN(name) enum class name
 #   define __VIC_SCOPED_ENUM_END(name) ; using name##_t = name;
 #else // C++98
 #   define __VIC_THROWS
-#   define __VIC_SWAP_HEADER <utility>
+#   define __VIC_SWAP_HEADER <algorithm>
 #   define __VIC_SCOPED_ENUM_UT_BEGIN(name,type) struct name { enum type_
 #   define __VIC_SCOPED_ENUM_BEGIN(name) struct name { enum type_
 #   define __VIC_SCOPED_ENUM_END(name) ; }; typedef name::type_ name##_t;
@@ -254,7 +254,7 @@
 #if __cpp_rvalue_references
 #   define __VIC_STD_MOVE(v) std::move(v)
 #else
-#   define __VIC_STD_MOVE(v) v
+#   define __VIC_STD_MOVE(v) (v)
 #endif
 
 #if __cpp_constexpr
@@ -273,6 +273,12 @@
 #   define __VIC_CONSTEXPR14 inline
 #endif
 
+#if __cpp_inline_variables
+#   define __VIC_INLINE_CONSTEXPR_VAR inline __VIC_CONSTEXPR_VAR
+#else
+#   define __VIC_INLINE_CONSTEXPR_VAR __VIC_CONSTEXPR_VAR
+#endif
+
 #if __cpp_if_consteval
 #   define __VIC_IF_CONSTEVAL if consteval
 #   define __VIC_IF_NOT_CONSTEVAL if !consteval

+ 1 - 6
include/__vic/ascii.h

@@ -10,11 +10,6 @@
 
 #include<__vic/defs.h>
 
-// FreeBSD 10 defines this
-#ifdef isascii
-#undef isascii
-#endif
-
 namespace __vic { namespace ascii {
 
 //----------------------------------------------------------------------------
@@ -81,7 +76,7 @@ __VIC_CONSTEXPR_FUNC bool iscntrl(char c)
     return (0 <= c && c <= '\x1F') || c == '\x7F';
 }
 //----------------------------------------------------------------------------
-__VIC_CONSTEXPR_FUNC bool isascii(char c)
+__VIC_CONSTEXPR_FUNC bool (isascii)(char c)
 {
     return static_cast<unsigned char>(c) < 0x7FU;
 }

+ 0 - 0
include/__vic/logger.h


Some files were not shown because too many files changed in this diff