diff --git a/examples/chapter04_04/build.bat b/examples/chapter04_04/build.bat
index c084aa050..5a1d767bb 100644
--- a/examples/chapter04_04/build.bat
+++ b/examples/chapter04_04/build.bat
@@ -1,6 +1,6 @@
@rem
-@rem Copyright Christopher Kormanyos 2014 - 2024.
+@rem Copyright Christopher Kormanyos 2014 - 2025.
@rem Distributed under the Boost Software License,
@rem Version 1.0. (See accompanying file LICENSE_1_0.txt
@rem or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -27,8 +27,8 @@
@set TOOL_PATH=%1
@set TOOL_PREFIX=%2
-@set CFLAGS=-Wall -Wextra -pedantic -mmcu=atmega328p -fsigned-char -O2 -fno-exceptions
-@set CPPFLAGS= -fno-rtti -fstrict-enums -fno-use-cxa-atexit -fno-use-cxa-get-exception-ptr -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs
+@set CFLAGS=-Wall -Wextra -Wpedantic -mmcu=atmega328p -fsigned-char -O2 -fno-exceptions
+@set CPPFLAGS=-std=c++14 -fno-rtti -fstrict-enums -fno-use-cxa-atexit -fno-use-cxa-get-exception-ptr -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs
@set CINCLUDES=-Isrc/util/STL -Isrc/mcal/avr -Isrc
@echo.
diff --git a/examples/chapter04_04/build.sh b/examples/chapter04_04/build.sh
index 0a330f91d..f4a1a8718 100755
--- a/examples/chapter04_04/build.sh
+++ b/examples/chapter04_04/build.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
-# Copyright Christopher Kormanyos 2014 - 2024.
+# Copyright Christopher Kormanyos 2014 - 2025.
# Distributed under the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -48,7 +48,7 @@ else
fi
CFLAGS="-Wall -Wextra -pedantic -mmcu=atmega328p -fsigned-char -O2 -fno-exceptions"
-CPPFLAGS=" -fno-rtti -fstrict-enums -fno-use-cxa-atexit -fno-use-cxa-get-exception-ptr -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs"
+CPPFLAGS="-std=c++14 -fno-rtti -fstrict-enums -fno-use-cxa-atexit -fno-use-cxa-get-exception-ptr -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs"
CINCLUDES="-Isrc/util/STL -Isrc/mcal/avr -Isrc"
echo
diff --git a/examples/chapter09_08/build.bat b/examples/chapter09_08/build.bat
index 8c0a51fc8..feff714bf 100644
--- a/examples/chapter09_08/build.bat
+++ b/examples/chapter09_08/build.bat
@@ -1,6 +1,6 @@
@rem
-@rem Copyright Christopher Kormanyos 2014 - 2021.
+@rem Copyright Christopher Kormanyos 2014 - 2025.
@rem Distributed under the Boost Software License,
@rem Version 1.0. (See accompanying file LICENSE_1_0.txt
@rem or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -27,7 +27,7 @@
@set TOOL_PATH=%1
@set TOOL_PREFIX=%2
-@set CFLAGS=-C -Wall -Wextra -pedantic -mmcu=atmega328p -fsigned-char -O2 -fno-exceptions -gdwarf-2 -ffunction-sections -fdata-sections
+@set CFLAGS=-Wall -Wextra -Wpedantic -mmcu=atmega328p -fsigned-char -O2 -fno-exceptions
@set CPPFLAGS=-std=c++14 -fno-rtti -fstrict-enums -fno-use-cxa-atexit -fno-use-cxa-get-exception-ptr -fno-nonansi-builtins -fno-threadsafe-statics -fno-enforce-eh-specs
@set CINCLUDES=-Isrc/util/STL_C++XX_stdfloat -Isrc/util/STL -Isrc -Isrc/mcal/avr
diff --git a/examples/chapter09_08/build.sh b/examples/chapter09_08/build.sh
index 5334731d2..d3b2e8246 100755
--- a/examples/chapter09_08/build.sh
+++ b/examples/chapter09_08/build.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
-# Copyright Christopher Kormanyos 2014 - 2020.
+# Copyright Christopher Kormanyos 2014 - 2025.
# Distributed under the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/examples/chapter09_08/chapter09_08.vcxproj b/examples/chapter09_08/chapter09_08.vcxproj
index 0cb41ee25..b098befcb 100644
--- a/examples/chapter09_08/chapter09_08.vcxproj
+++ b/examples/chapter09_08/chapter09_08.vcxproj
@@ -244,8 +244,8 @@
-
-
+
+
@@ -368,6 +368,10 @@
true
true
+
+ true
+ true
+
true
true
@@ -444,6 +448,10 @@
true
true
+
+ true
+ true
+
true
true
@@ -464,6 +472,10 @@
true
true
+
+ true
+ true
+
diff --git a/examples/chapter09_08/chapter09_08.vcxproj.filters b/examples/chapter09_08/chapter09_08.vcxproj.filters
index b3445ac78..08e8698a6 100644
--- a/examples/chapter09_08/chapter09_08.vcxproj.filters
+++ b/examples/chapter09_08/chapter09_08.vcxproj.filters
@@ -167,9 +167,6 @@
src\mcal
-
- src\mcal
-
src\os
@@ -179,9 +176,6 @@
src\os
-
- src\mcal
-
src\util\device
@@ -320,9 +314,6 @@
src\util\STL\impl\avr
-
- src\util\STL
-
src\util\utility
@@ -368,11 +359,35 @@
src\util\utility
+
+ src\mcal
+
+
+ src\mcal
+
+
+ src\util\STL
+
src\util\STL_C++XX_stdfloat
+
+ src\util\STL
+
+
+ src\util\STL
+
+
+ src\util\STL
+
+
+ src\util\STL
+
+
+ src\util\STL
+
src\util\STL
@@ -388,6 +403,9 @@
src\util\STL
+
+ src\util\STL
+
src\util\STL
@@ -403,6 +421,9 @@
src\util\STL
+
+ src\util\STL
+
src\util\STL
@@ -439,6 +460,9 @@
src\util\STL
+
+ src\util\STL
+
src\util\STL
@@ -466,21 +490,6 @@
src\util\STL
-
- src\util\STL
-
-
- src\util\STL
-
-
- src\util\STL
-
-
- src\util\STL
-
-
- src\util\STL
-
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_benchmark.h b/examples/chapter09_08/src/mcal/avr/mcal_benchmark.h
index e573589de..bef2f15db 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_benchmark.h
+++ b/examples/chapter09_08/src/mcal/avr/mcal_benchmark.h
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2014.
+// Copyright Christopher Kormanyos 2014 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -8,18 +8,19 @@
#ifndef MCAL_BENCHMARK_2014_04_16_H_
#define MCAL_BENCHMARK_2014_04_16_H_
- #include
#include
#include
+ #include
+
namespace mcal
{
namespace benchmark
{
- typedef mcal::port::port_pin benchmark_port_type;
+ using benchmark_port_type = mcal::port::port_pin;
}
}
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_cpu.cpp b/examples/chapter09_08/src/mcal/avr/mcal_cpu.cpp
index 563fa3ca9..3f5184e27 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_cpu.cpp
+++ b/examples/chapter09_08/src/mcal/avr/mcal_cpu.cpp
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2018.
+// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -10,7 +10,7 @@
#include
#include
-void mcal::cpu::init()
+auto mcal::cpu::init() -> void
{
mcal::wdg::init(nullptr);
mcal::port::init(nullptr);
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_cpu.h b/examples/chapter09_08/src/mcal/avr/mcal_cpu.h
index 628cdd28e..0c8cb16c9 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_cpu.h
+++ b/examples/chapter09_08/src/mcal/avr/mcal_cpu.h
@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2020.
+// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef MCAL_CPU_2009_02_14_H_
- #define MCAL_CPU_2009_02_14_H_
+#ifndef MCAL_CPU_2009_02_14_H
+ #define MCAL_CPU_2009_02_14_H
#include
@@ -16,10 +16,10 @@
{
void init();
- inline void post_init() { }
+ inline auto post_init() -> void { }
- inline void nop() noexcept { asm volatile("nop"); }
+ inline auto nop() noexcept -> void { asm volatile("nop"); }
}
}
-#endif // MCAL_CPU_2009_02_14_H_
+#endif // MCAL_CPU_2009_02_14_H
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_gpt.cpp b/examples/chapter09_08/src/mcal/avr/mcal_gpt.cpp
index a0b40b852..f1f87278e 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_gpt.cpp
+++ b/examples/chapter09_08/src/mcal/avr/mcal_gpt.cpp
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2015.
+// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_gpt.h b/examples/chapter09_08/src/mcal/avr/mcal_gpt.h
index 30ca79fd4..7732283ca 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_gpt.h
+++ b/examples/chapter09_08/src/mcal/avr/mcal_gpt.h
@@ -1,18 +1,18 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2020.
+// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef MCAL_GPT_2011_10_20_H_
- #define MCAL_GPT_2011_10_20_H_
+#ifndef MCAL_GPT_2011_10_20_H
+ #define MCAL_GPT_2011_10_20_H
+
+ #include
#include
#include
- #include
-
// Forward declaration of the util::timer template class.
namespace util
{
@@ -24,16 +24,16 @@
{
namespace gpt
{
- typedef void config_type;
- typedef std::uint32_t value_type;
+ using config_type = void;
+ using value_type = std::uint64_t;
- void init(const config_type*);
+ auto init(const config_type*) -> void;
class secure final
{
static value_type get_time_elapsed();
- friend std::chrono::high_resolution_clock::time_point std::chrono::high_resolution_clock::now() UTIL_NOEXCEPT;
+ friend auto std::chrono::high_resolution_clock::now() -> std::chrono::high_resolution_clock::time_point;
template
friend class util::timer;
@@ -41,4 +41,4 @@
}
}
-#endif // MCAL_GPT_2011_10_20_H_
+#endif // MCAL_GPT_2011_10_20_H
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_irq.cpp b/examples/chapter09_08/src/mcal/avr/mcal_irq.cpp
index f9f983c47..5e60cf497 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_irq.cpp
+++ b/examples/chapter09_08/src/mcal/avr/mcal_irq.cpp
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2013.
+// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -7,7 +7,7 @@
#include
-void mcal::irq::init(const config_type*)
+auto mcal::irq::init(const config_type*) -> void
{
mcal::irq::enable_all();
}
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_irq.h b/examples/chapter09_08/src/mcal/avr/mcal_irq.h
index 4f650ed54..1adbd9536 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_irq.h
+++ b/examples/chapter09_08/src/mcal/avr/mcal_irq.h
@@ -1,24 +1,24 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2013.
+// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef MCAL_IRQ_2010_04_10_H_
- #define MCAL_IRQ_2010_04_10_H_
+#ifndef MCAL_IRQ_2010_04_10_H
+ #define MCAL_IRQ_2010_04_10_H
namespace mcal
{
namespace irq
{
- typedef void config_type;
+ using config_type = void;
- void init(const config_type*);
+ auto init(const config_type*) -> void;
- inline void enable_all () { asm volatile("sei"); }
- inline void disable_all() { asm volatile("cli"); }
+ inline auto enable_all () noexcept -> void { asm volatile("sei"); }
+ inline auto disable_all() noexcept -> void { asm volatile("cli"); }
}
}
-#endif // MCAL_IRQ_2010_04_10_H_
+#endif // MCAL_IRQ_2010_04_10_H
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_led_monochrome.cpp b/examples/chapter09_08/src/mcal/avr/mcal_led_monochrome.cpp
index 0fc223abd..fe7417bea 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_led_monochrome.cpp
+++ b/examples/chapter09_08/src/mcal/avr/mcal_led_monochrome.cpp
@@ -1,19 +1,21 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2017 - 2018.
+// Copyright Christopher Kormanyos 2017 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include
+#include
#include
#include
-#include
util::device::led_monochrome& mcal::led::led_monochrome0()
{
- static mcal::led::led_momochrome_board the_led;
+ using local_led_mponochrome_type =
+ mcal::led::led_momochrome_board;
+
+ static local_led_mponochrome_type the_led { };
return the_led;
}
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_led_monochrome_board.h b/examples/chapter09_08/src/mcal/avr/mcal_led_monochrome_board.h
index 4197061c0..bab49d824 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_led_monochrome_board.h
+++ b/examples/chapter09_08/src/mcal/avr/mcal_led_monochrome_board.h
@@ -1,18 +1,18 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2017 - 2018.
+// Copyright Christopher Kormanyos 2017 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef MCAL_LED_MONOCHROME_BOARD_2017_09_14_H_
- #define MCAL_LED_MONOCHROME_BOARD_2017_09_14_H_
-
- #include
+#ifndef MCAL_LED_MONOCHROME_BOARD_2017_09_14_H
+ #define MCAL_LED_MONOCHROME_BOARD_2017_09_14_H
#include
#include
+ #include
+
namespace mcal
{
namespace led
@@ -31,14 +31,14 @@
port_pin_type::set_direction_output();
}
- virtual ~led_momochrome_board() { }
+ ~led_momochrome_board() override = default;
- virtual void my_on()
+ auto my_on() -> void override
{
port_pin_type::set_pin_high();
}
- virtual void my_off()
+ auto my_off()-> void override
{
port_pin_type::set_pin_low();
}
@@ -53,4 +53,4 @@
}
}
-#endif // MCAL_LED_MONOCHROME_BOARD_2017_09_14_H_
+#endif // MCAL_LED_MONOCHROME_BOARD_2017_09_14_H
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_led_rgb.cpp b/examples/chapter09_08/src/mcal/avr/mcal_led_rgb.cpp
index 6dd54fec5..aa0a6e44f 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_led_rgb.cpp
+++ b/examples/chapter09_08/src/mcal/avr/mcal_led_rgb.cpp
@@ -10,9 +10,9 @@
#include
#include
-util::device::led_rgb& mcal::led::led_rgb0()
+auto mcal::led::led_rgb0() -> util::device::led_rgb&
{
- static mcal::led::led_rgb_board the_rgb_led;
+ static mcal::led::led_rgb_board the_rgb_led { };
return the_rgb_led;
}
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_led_rgb_board.cpp b/examples/chapter09_08/src/mcal/avr/mcal_led_rgb_board.cpp
index 07e869c02..b0402bf42 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_led_rgb_board.cpp
+++ b/examples/chapter09_08/src/mcal/avr/mcal_led_rgb_board.cpp
@@ -1,16 +1,14 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2017 - 2018.
+// Copyright Christopher Kormanyos 2017 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#include
-
#include
#include
-void mcal::led::led_rgb_board::apply_color()
+auto mcal::led::led_rgb_board::apply_color() -> void
{
const uint_fast8_t my_r = uint_fast8_t(uint_fast16_t(uint_fast16_t(255U - get_hue_r()) * 100U) / 255U);
const uint_fast8_t my_g = uint_fast8_t(uint_fast16_t(uint_fast16_t(255U - get_hue_g()) * 100U) / 255U);
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_led_rgb_board.h b/examples/chapter09_08/src/mcal/avr/mcal_led_rgb_board.h
index 03daa9ec7..dd8739f79 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_led_rgb_board.h
+++ b/examples/chapter09_08/src/mcal/avr/mcal_led_rgb_board.h
@@ -1,18 +1,18 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2017 - 2018.
+// Copyright Christopher Kormanyos 2017 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef MCAL_LED_RGB_BOARD_2017_11_12_H_
- #define MCAL_LED_RGB_BOARD_2017_11_12_H_
-
- #include
+#ifndef MCAL_LED_RGB_BOARD_2017_11_12_H
+ #define MCAL_LED_RGB_BOARD_2017_11_12_H
#include
#include
+ #include
+
namespace mcal { namespace led {
// The RGB LED on the board is controlled with 3 digital PWM signals.
@@ -20,14 +20,14 @@
class led_rgb_board final : public util::device::led_rgb
{
public:
- led_rgb_board() { }
+ led_rgb_board() = default;
- virtual ~led_rgb_board() { }
+ ~led_rgb_board() override = default;
private:
- virtual void apply_color();
+ auto apply_color() -> void override;
};
} } // namespace mcal::led
-#endif // MCAL_LED_RGB_BOARD_2017_11_12_H_
+#endif // MCAL_LED_RGB_BOARD_2017_11_12_H
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_led_sys_start_interface.cpp b/examples/chapter09_08/src/mcal/avr/mcal_led_sys_start_interface.cpp
index db169c6f9..39be0176b 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_led_sys_start_interface.cpp
+++ b/examples/chapter09_08/src/mcal/avr/mcal_led_sys_start_interface.cpp
@@ -7,9 +7,9 @@
#include
-bool& mcal::led::sys_start_interface::my_exit_pc_api_flag()
+auto mcal::led::sys_start_interface::my_exit_pc_api_flag() -> bool&
{
- static bool my_flag;
+ static bool my_flag { };
return my_flag;
}
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_led_sys_start_interface.h b/examples/chapter09_08/src/mcal/avr/mcal_led_sys_start_interface.h
index b2673691c..232bf70ee 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_led_sys_start_interface.h
+++ b/examples/chapter09_08/src/mcal/avr/mcal_led_sys_start_interface.h
@@ -1,22 +1,22 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2017 - 2018.
+// Copyright Christopher Kormanyos 2017 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef MCAL_LED_SYS_START_INTERFACE_2017_11_21_H_
- #define MCAL_LED_SYS_START_INTERFACE_2017_11_21_H_
+#ifndef MCAL_LED_SYS_START_INTERFACE_2017_11_21_H
+ #define MCAL_LED_SYS_START_INTERFACE_2017_11_21_H
namespace mcal { namespace led {
struct sys_start_interface
{
- static void my_sys_start();
+ static auto my_sys_start() -> void;
- static bool& my_exit_pc_api_flag();
+ static auto my_exit_pc_api_flag() -> bool&;
};
} } // namespace mcal::led
-#endif // MCAL_LED_SYS_START_INTERFACE_2017_11_21_H_
+#endif // MCAL_LED_SYS_START_INTERFACE_2017_11_21_H
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_memory_progmem.h b/examples/chapter09_08/src/mcal/avr/mcal_memory_progmem.h
index e4bc7f0ec..69812a21a 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_memory_progmem.h
+++ b/examples/chapter09_08/src/mcal/avr/mcal_memory_progmem.h
@@ -1,17 +1,17 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2019 - 2020.
+// Copyright Christopher Kormanyos 2019 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef MCAL_MEMORY_PROGMEM_2019_08_17_H_
- #define MCAL_MEMORY_PROGMEM_2019_08_17_H_
-
- #include
+#ifndef MCAL_MEMORY_PROGMEM_2019_08_17_H
+ #define MCAL_MEMORY_PROGMEM_2019_08_17_H
#include
+ #include
+
#define MY_PROGMEM PROGMEM
#if defined(__cplusplus)
@@ -59,4 +59,4 @@
}
#endif
-#endif // MCAL_MEMORY_PROGMEM_2019_08_17_H_
+#endif // MCAL_MEMORY_PROGMEM_2019_08_17_H
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_osc.cpp b/examples/chapter09_08/src/mcal/avr/mcal_osc.cpp
index 14787d20a..6ae0b6324 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_osc.cpp
+++ b/examples/chapter09_08/src/mcal/avr/mcal_osc.cpp
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2013.
+// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -7,6 +7,6 @@
#include
-void mcal::osc::init(const config_type*)
+auto mcal::osc::init(const config_type*) -> void
{
}
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_osc.h b/examples/chapter09_08/src/mcal/avr/mcal_osc.h
index 59b729640..cb8944d84 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_osc.h
+++ b/examples/chapter09_08/src/mcal/avr/mcal_osc.h
@@ -1,21 +1,21 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2013.
+// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef MCAL_OSC_2011_10_20_H_
- #define MCAL_OSC_2011_10_20_H_
+#ifndef MCAL_OSC_2011_10_20_H
+ #define MCAL_OSC_2011_10_20_H
namespace mcal
{
namespace osc
{
- typedef void config_type;
+ using config_type = void;
- void init(const config_type*);
+ auto init(const config_type*) -> void;
}
}
-#endif // MCAL_OSC_2011_10_20_H_
+#endif // MCAL_OSC_2011_10_20_H
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_port.cpp b/examples/chapter09_08/src/mcal/avr/mcal_port.cpp
index 4486c3fe8..e19b30c3b 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_port.cpp
+++ b/examples/chapter09_08/src/mcal/avr/mcal_port.cpp
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2018.
+// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -7,6 +7,6 @@
#include
-void mcal::port::init(const config_type*)
+auto mcal::port::init(const config_type*) -> void
{
}
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_port.h b/examples/chapter09_08/src/mcal/avr/mcal_port.h
index 077cb66c2..fbe2a2bd2 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_port.h
+++ b/examples/chapter09_08/src/mcal/avr/mcal_port.h
@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2020.
+// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef MCAL_PORT_2012_06_27_H_
- #define MCAL_PORT_2012_06_27_H_
+#ifndef MCAL_PORT_2012_06_27_H
+ #define MCAL_PORT_2012_06_27_H
#include
@@ -14,9 +14,9 @@
{
namespace port
{
- typedef void config_type;
+ using config_type = void;
- void init(const config_type*);
+ auto init(const config_type*) -> void;
template void
{
// Set the port pin's direction to output.
// C++:
@@ -46,7 +46,7 @@
asm volatile("sbi %[myport],%[mybit]" : : [myport]"I"(pdir_address - sfr_offset), [mybit]"I"(bpos_value));
}
- static void set_direction_input()
+ static auto set_direction_input() -> void
{
// Set the port pin's direction to input.
// C++:
@@ -57,7 +57,7 @@
asm volatile("cbi %[myport],%[mybit]" : : [myport]"I"(pdir_address - sfr_offset), [mybit]"I"(bpos_value));
}
- static void set_pin_high()
+ static auto set_pin_high() -> void
{
// Set the port output value to high.
// C++:
@@ -68,7 +68,7 @@
asm volatile("sbi %[myport],%[mybit]" : : [myport]"I"(port_address - sfr_offset), [mybit]"I"(bpos_value));
}
- static void set_pin_low()
+ static auto set_pin_low() -> void
{
// Set the port output value to low.
// C++:
@@ -79,7 +79,7 @@
asm volatile("cbi %[myport],%[mybit]" : : [myport]"I"(port_address - sfr_offset), [mybit]"I"(bpos_value));
}
- static bool read_input_value()
+ static auto read_input_value() -> bool
{
// Read the port input value.
return mcal::reg::reg_access_static::bit_get();
}
- static void toggle_pin()
+ static auto toggle_pin() -> void
{
// Toggle the port output value.
mcal::reg::reg_access_static
-
#include
#include
#include
#include
-mcal::pwm::pwm_base& mcal::pwm::mcal_pwm0()
+#include
+
+auto mcal::pwm::mcal_pwm0() -> mcal::pwm::pwm_base&
{
using port0_type = mcal::port::port_pin;
- static pwm0_type the_pwm0(100U, 100U);
+ using local_duty_type = typename pwm0_type::duty_type;
+
+ static pwm0_type the_pwm0(local_duty_type { UINT8_C(100) });
return the_pwm0;
}
-mcal::pwm::pwm_base& mcal::pwm::mcal_pwm1()
+auto mcal::pwm::mcal_pwm1() -> mcal::pwm::pwm_base&
{
using port1_type = mcal::port::port_pin;
- static pwm1_type the_pwm1(100U, 100U);
+ using local_duty_type = typename pwm1_type::duty_type;
+
+ static pwm1_type the_pwm1(local_duty_type { UINT8_C(100) });
return the_pwm1;
}
-mcal::pwm::pwm_base& mcal::pwm::mcal_pwm2()
+auto mcal::pwm::mcal_pwm2() -> mcal::pwm::pwm_base&
{
using port2_type = mcal::port::port_pin;
- static pwm2_type the_pwm2(100U);
+ using local_duty_type = typename pwm2_type::duty_type;
+
+ static pwm2_type the_pwm2(local_duty_type { UINT8_C(100) });
return the_pwm2;
}
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_pwm.h b/examples/chapter09_08/src/mcal/avr/mcal_pwm.h
index a44e92e6e..ad45d22ce 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_pwm.h
+++ b/examples/chapter09_08/src/mcal/avr/mcal_pwm.h
@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2013.
+// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef MCAL_PWM_2018_01_08_H_
- #define MCAL_PWM_2018_01_08_H_
+#ifndef MCAL_PWM_2018_01_08_H
+ #define MCAL_PWM_2018_01_08_H
#include
@@ -14,10 +14,10 @@
{
namespace pwm
{
- pwm_base& mcal_pwm0();
- pwm_base& mcal_pwm1();
- pwm_base& mcal_pwm2();
+ auto mcal_pwm0() -> pwm_base&;
+ auto mcal_pwm1() -> pwm_base&;
+ auto mcal_pwm2() -> pwm_base&;
}
}
-#endif // MCAL_PWM_2018_01_08_H_
+#endif // MCAL_PWM_2018_01_08_H
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_pwm_board.h b/examples/chapter09_08/src/mcal/avr/mcal_pwm_board.h
index 08df70f79..89132326b 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_pwm_board.h
+++ b/examples/chapter09_08/src/mcal/avr/mcal_pwm_board.h
@@ -1,15 +1,12 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2018.
+// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef MCAL_PWM_BOARD_2017_10_13_H_
- #define MCAL_PWM_BOARD_2017_10_13_H_
-
- #include
- #include
+#ifndef MCAL_PWM_BOARD_2017_10_13_H
+ #define MCAL_PWM_BOARD_2017_10_13_H
#include
#include
@@ -28,15 +25,16 @@
class pwm_board : public pwm_base
{
public:
- pwm_board(const duty_type resol,
- const duty_type duty = 0U) : pwm_base(resol, duty)
+ explicit pwm_board(const duty_type resol,
+ const duty_type duty = duty_type { UINT8_C(0) })
+ : pwm_base(resol, duty)
{
// Set the port pin to output with logic level low.
port_pin_type::set_pin_low();
port_pin_type::set_direction_output();
}
- virtual void service()
+ auto service() -> void override
{
// Increment the counter.
++counter;
@@ -58,11 +56,11 @@
duty_cycle = shadow;
// Reset the counter for a new PWM period.
- counter = 0U;
+ counter = duty_type { UINT8_C(0) };
}
}
};
}
}
-#endif // MCAL_PWM_BOARD_2017_10_13_H_
+#endif // MCAL_PWM_BOARD_2017_10_13_H
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_reg.h b/examples/chapter09_08/src/mcal/avr/mcal_reg.h
index d402fae64..62e084ec2 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_reg.h
+++ b/examples/chapter09_08/src/mcal/avr/mcal_reg.h
@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2020.
+// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef MCAL_REG_2010_04_10_H_
- #define MCAL_REG_2010_04_10_H_
+#ifndef MCAL_REG_2010_04_10_H
+ #define MCAL_REG_2010_04_10_H
#include
@@ -17,76 +17,91 @@
constexpr std::uint8_t sfr_offset = 0x20U;
// Bit-position values.
- constexpr std::uint8_t bval0 = 1U;
- constexpr std::uint8_t bval1 = 1U << 1U;
- constexpr std::uint8_t bval2 = 1U << 2U;
- constexpr std::uint8_t bval3 = 1U << 3U;
- constexpr std::uint8_t bval4 = 1U << 4U;
- constexpr std::uint8_t bval5 = 1U << 5U;
- constexpr std::uint8_t bval6 = 1U << 6U;
- constexpr std::uint8_t bval7 = 1U << 7U;
+ constexpr std::uint8_t bval0 { 1U };
+ constexpr std::uint8_t bval1 { 1U << 1U };
+ constexpr std::uint8_t bval2 { 1U << 2U };
+ constexpr std::uint8_t bval3 { 1U << 3U };
+ constexpr std::uint8_t bval4 { 1U << 4U };
+ constexpr std::uint8_t bval5 { 1U << 5U };
+ constexpr std::uint8_t bval6 { 1U << 6U };
+ constexpr std::uint8_t bval7 { 1U << 7U };
// System registers.
- constexpr std::uint8_t mcusr = 0x14U + sfr_offset;
- constexpr std::uint8_t prr = 0x64U;
+ constexpr std::uint8_t mcusr { 0x14U + sfr_offset };
+ constexpr std::uint8_t prr { 0x64U };
// Port registers.
- constexpr std::uint8_t pinb = 0x03U + sfr_offset;
- constexpr std::uint8_t ddrb = 0x04U + sfr_offset;
- constexpr std::uint8_t portb = 0x05U + sfr_offset;
- constexpr std::uint8_t pinc = 0x06U + sfr_offset;
- constexpr std::uint8_t ddrc = 0x07U + sfr_offset;
- constexpr std::uint8_t portc = 0x08U + sfr_offset;
- constexpr std::uint8_t pind = 0x09U + sfr_offset;
- constexpr std::uint8_t ddrd = 0x0AU + sfr_offset;
- constexpr std::uint8_t portd = 0x0BU + sfr_offset;
- constexpr std::uint8_t pine = 0x0CU + sfr_offset;
- constexpr std::uint8_t ddre = 0x0DU + sfr_offset;
- constexpr std::uint8_t porte = 0x0EU + sfr_offset;
+ constexpr std::uint8_t pinb { 0x03U + sfr_offset };
+ constexpr std::uint8_t ddrb { 0x04U + sfr_offset };
+ constexpr std::uint8_t portb { 0x05U + sfr_offset };
+ constexpr std::uint8_t pinc { 0x06U + sfr_offset };
+ constexpr std::uint8_t ddrc { 0x07U + sfr_offset };
+ constexpr std::uint8_t portc { 0x08U + sfr_offset };
+ constexpr std::uint8_t pind { 0x09U + sfr_offset };
+ constexpr std::uint8_t ddrd { 0x0AU + sfr_offset };
+ constexpr std::uint8_t portd { 0x0BU + sfr_offset };
+ constexpr std::uint8_t pine { 0x0CU + sfr_offset };
+ constexpr std::uint8_t ddre { 0x0DU + sfr_offset };
+ constexpr std::uint8_t porte { 0x0EU + sfr_offset };
+
+ // Timer register values
+ constexpr std::uint8_t cs10 = 0U;
+ constexpr std::uint8_t cs11 = 1U;
+ constexpr std::uint8_t cs12 = 2U;
+ constexpr std::uint8_t wgm12 = 3U;
+ constexpr std::uint8_t toie1 = 0U;
+ constexpr std::uint8_t ocie0a = 1U;
+ constexpr std::uint8_t ocie0b = 2U;
+ constexpr std::uint8_t toie0 = 0U;
+ constexpr std::uint8_t ocie1a = 1U;
+ constexpr std::uint8_t ocie1b = 2U;
+ constexpr std::uint8_t toie2 = 0U;
+ constexpr std::uint8_t ocie2a = 1U;
+ constexpr std::uint8_t ocie2b = 2U;
// Timer registers
- constexpr std::uint8_t tifr0 = 0x15U + sfr_offset;
- constexpr std::uint8_t tccr0a = 0x24U + sfr_offset;
- constexpr std::uint8_t tccr0b = 0x25U + sfr_offset;
- constexpr std::uint8_t tcnt0 = 0x26U + sfr_offset;
- constexpr std::uint8_t ocr0a = 0x27U + sfr_offset;
- constexpr std::uint8_t timsk0 = 0x6EU;
+ constexpr std::uint8_t tifr0 { 0x15U + sfr_offset };
+ constexpr std::uint8_t tccr0a { 0x24U + sfr_offset };
+ constexpr std::uint8_t tccr0b { 0x25U + sfr_offset };
+ constexpr std::uint8_t tcnt0 { 0x26U + sfr_offset };
+ constexpr std::uint8_t ocr0a { 0x27U + sfr_offset };
+ constexpr std::uint8_t timsk0 { 0x6EU };
- constexpr std::uint8_t tifr1 = 0x16U + sfr_offset;
- constexpr std::uint8_t tccr1a = 0x80U;
- constexpr std::uint8_t tccr1b = 0x81U;
- constexpr std::uint8_t tcnt1l = 0x84U;
- constexpr std::uint8_t tcnt1h = 0x85U;
- constexpr std::uint8_t icr1 = 0x86U; // 16-bit register
- constexpr std::uint8_t ocr1a = 0x88U; // 16-bit register
- constexpr std::uint8_t ocr1b = 0x8AU; // 16-bit register
- constexpr std::uint8_t timsk1 = 0x6FU;
+ constexpr std::uint8_t tifr1 { 0x16U + sfr_offset };
+ constexpr std::uint8_t tccr1a { 0x80U };
+ constexpr std::uint8_t tccr1b { 0x81U };
+ constexpr std::uint8_t tcnt1l { 0x84U };
+ constexpr std::uint8_t tcnt1h { 0x85U };
+ constexpr std::uint8_t icr1 { 0x86U }; // 16-bit register
+ constexpr std::uint8_t ocr1a { 0x88U }; // 16-bit register
+ constexpr std::uint8_t ocr1b { 0x8AU }; // 16-bit register
+ constexpr std::uint8_t timsk1 { 0x6FU };
- constexpr std::uint8_t tifr2 = 0x17U + sfr_offset;
- constexpr std::uint8_t tccr2a = 0xB0U;
- constexpr std::uint8_t tccr2b = 0xB1U;
- constexpr std::uint8_t tcnt2 = 0xB2U;
- constexpr std::uint8_t ocr2a = 0xB3U;
- constexpr std::uint8_t timsk2 = 0x70U;
+ constexpr std::uint8_t tifr2 { 0x17U + sfr_offset };
+ constexpr std::uint8_t tccr2a { 0xB0U };
+ constexpr std::uint8_t tccr2b { 0xB1U };
+ constexpr std::uint8_t tcnt2 { 0xB2U };
+ constexpr std::uint8_t ocr2a { 0xB3U };
+ constexpr std::uint8_t timsk2 { 0x70U };
// SPI(TM) registers.
- constexpr std::uint8_t spcr = 0x2CU + sfr_offset;
- constexpr std::uint8_t spsr = 0x2DU + sfr_offset;
- constexpr std::uint8_t spdr = 0x2EU + sfr_offset;
+ constexpr std::uint8_t spcr { 0x2CU + sfr_offset };
+ constexpr std::uint8_t spsr { 0x2DU + sfr_offset };
+ constexpr std::uint8_t spdr { 0x2EU + sfr_offset };
// Watchdog registers
- constexpr std::uint8_t wdtcsr = 0x60U;
+ constexpr std::uint8_t wdtcsr { 0x60U };
// Eeprom registers
- constexpr std::uint8_t eecr = 0x1FU + sfr_offset;
- constexpr std::uint8_t eedr = 0x20U + sfr_offset;
- constexpr std::uint8_t eear = 0x21U + sfr_offset;
- constexpr std::uint8_t eearl = 0x21U + sfr_offset;
- constexpr std::uint8_t eearh = 0x22U + sfr_offset;
+ constexpr std::uint8_t eecr { 0x1FU + sfr_offset };
+ constexpr std::uint8_t eedr { 0x20U + sfr_offset };
+ constexpr std::uint8_t eear { 0x21U + sfr_offset };
+ constexpr std::uint8_t eearl { 0x21U + sfr_offset };
+ constexpr std::uint8_t eearh { 0x22U + sfr_offset };
}
}
#include
#include
-#endif // MCAL_REG_2010_04_10_H_
+#endif // MCAL_REG_2010_04_10_H
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_wdg.cpp b/examples/chapter09_08/src/mcal/avr/mcal_wdg.cpp
index ab4e54b7e..2165648cd 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_wdg.cpp
+++ b/examples/chapter09_08/src/mcal/avr/mcal_wdg.cpp
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2013.
+// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -8,12 +8,7 @@
#include
#include
-// This following function is not used.
-// It is, however, kept as an example of *turning off*
-// the wdt if wdton is set in the fuse bits.
-void mcal_wdg_turn_off_wdt_if_wdton_is_set();
-
-void mcal::wdg::init(const config_type*)
+auto mcal::wdg::init(const config_type*) -> void
{
// Read the MCU status register.
volatile const std::uint8_t mcu_status_register =
@@ -34,45 +29,32 @@ void mcal::wdg::init(const config_type*)
// Reset the watchdog timer.
asm volatile("wdr");
- // Set the watchdog timer period and activate the watchdog timer.
+ // Start timed sequence in order to set the watchdog
+ // timer period and activate the watchdog timer.
mcal::reg::reg_access_static::reg_set();
- // See Chapter 11.9.2, Table 11-2: Watchdog Timer Prescale Select.
- // Select WDP3:WDP0 in WDTCSR to binary 0011, resulting in a watchdog
- // period of approximately 125ms.
+ // In "Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf",
+ // see Chapter 10.9.2, Table 10-3: Watchdog Timer Prescale Select.
+ // Set WDP3 (bit 5) and clear WDP2:WDP0 (bits 0, 1 and 2) in WDTCSR
+ // (i.e., set to hex 0x20). This results in a watchdog period
+ // of approximately 4s.
mcal::reg::reg_access_static::reg_set();
-}
-
-void mcal::wdg::secure::trigger()
-{
- asm volatile("wdr");
-}
+ std::uint8_t(0x20U)>::reg_set();
-void mcal_wdg_turn_off_wdt_if_wdton_is_set()
-{
- asm volatile("wdr");
-
- // Clear WDRF in the MCU status register.
+ // Set WDRF in the MCU status register.
mcal::reg::reg_access_static::bit_clr();
-
- // Set WDCE and WDE.
- mcal::reg::reg_access_static::reg_or();
+ std::uint8_t(3U)>::bit_set();
+}
- // Turn off the WDT.
- mcal::reg::reg_access_static::reg_set();
+auto mcal::wdg::secure::trigger() -> void
+{
+ asm volatile("wdr");
}
+
diff --git a/examples/chapter09_08/src/mcal/avr/mcal_wdg.h b/examples/chapter09_08/src/mcal/avr/mcal_wdg.h
index 97527bb64..8e8141310 100644
--- a/examples/chapter09_08/src/mcal/avr/mcal_wdg.h
+++ b/examples/chapter09_08/src/mcal/avr/mcal_wdg.h
@@ -1,34 +1,34 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2018.
+// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef MCAL_WDT_2010_04_10_H_
- #define MCAL_WDT_2010_04_10_H_
+#ifndef MCAL_WDT_2010_04_10_H
+ #define MCAL_WDT_2010_04_10_H
extern "C" void __my_startup() __attribute__((section(".startup"), used, noinline));
- namespace sys { namespace idle { void task_func(); } }
+ namespace sys { namespace idle { auto task_func() -> void; } }
namespace mcal
{
namespace wdg
{
- typedef void config_type;
+ using config_type = void;
- void init(const config_type*);
+ auto init(const config_type*) -> void;
struct secure final
{
private:
- static void trigger();
+ static auto trigger() -> void;
- friend void ::sys::idle::task_func();
- friend void ::__my_startup();
+ friend auto ::sys::idle::task_func() -> void;
+ friend auto ::__my_startup() -> void;
};
}
}
-#endif // MCAL_WDT_2010_04_10_H_
+#endif // MCAL_WDT_2010_04_10_H
diff --git a/examples/chapter09_08/src/mcal/mcal.cpp b/examples/chapter09_08/src/mcal/mcal.cpp
index 06c77cb46..6de73807a 100644
--- a/examples/chapter09_08/src/mcal/mcal.cpp
+++ b/examples/chapter09_08/src/mcal/mcal.cpp
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2019.
+// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -7,7 +7,7 @@
#include
-void mcal::init()
+auto mcal::init() -> void
{
// Initialize the microcontroller abstraction layer.
diff --git a/examples/chapter09_08/src/mcal/mcal.h b/examples/chapter09_08/src/mcal/mcal.h
index 7676cfed7..d3347fbf7 100644
--- a/examples/chapter09_08/src/mcal/mcal.h
+++ b/examples/chapter09_08/src/mcal/mcal.h
@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2018.
+// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef MCAL_2011_10_20_H_
- #define MCAL_2011_10_20_H_
+#ifndef MCAL_2011_10_20_H
+ #define MCAL_2011_10_20_H
#include
#include
@@ -14,14 +14,14 @@
#include
#include
- static_assert( (std::numeric_limits::digits >= 32)
- && (std::numeric_limits::is_integer == true)
- && (std::numeric_limits::is_signed == false),
+ static_assert( (std::numeric_limits::digits >= 32)
+ && std::numeric_limits::is_integer
+ && (!std::numeric_limits::is_signed),
"The gpt value type must be an unsigned integer type having at least 32 bits");
namespace mcal
{
- void init();
- }
+ auto init() -> void;
+ } // namespace mcal
-#endif // MCAL_2011_10_20_H_
+#endif // MCAL_2011_10_20_H
diff --git a/examples/chapter09_08/src/mcal/mcal_led_rgb.h b/examples/chapter09_08/src/mcal/mcal_led_rgb.h
index 6cc458b11..e805fe250 100644
--- a/examples/chapter09_08/src/mcal/mcal_led_rgb.h
+++ b/examples/chapter09_08/src/mcal/mcal_led_rgb.h
@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2017 - 2018.
+// Copyright Christopher Kormanyos 2017 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef MCAL_LED_RGB_2017_11_12_H_
- #define MCAL_LED_RGB_2017_11_12_H_
+#ifndef MCAL_LED_RGB_2017_11_12_H
+ #define MCAL_LED_RGB_2017_11_12_H
#include
@@ -14,8 +14,8 @@
{
namespace led
{
- util::device::led_rgb& led_rgb0();
+ auto led_rgb0() -> util::device::led_rgb&;
}
}
-#endif // MCAL_LED_RGB_2017_11_12_H_
+#endif // MCAL_LED_RGB_2017_11_12_H
diff --git a/examples/chapter09_08/src/mcal/mcal_pwm_base.h b/examples/chapter09_08/src/mcal/mcal_pwm_base.h
index e3c16d2cf..dfc8ecaa7 100644
--- a/examples/chapter09_08/src/mcal/mcal_pwm_base.h
+++ b/examples/chapter09_08/src/mcal/mcal_pwm_base.h
@@ -1,19 +1,19 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2018.
+// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef MCAL_PWM_BASE_2017_10_13_H_
- #define MCAL_PWM_BASE_2017_10_13_H_
-
- #include
- #include
+#ifndef MCAL_PWM_BASE_2017_10_13_H
+ #define MCAL_PWM_BASE_2017_10_13_H
#include
#include
+ #include
+ #include
+
namespace mcal
{
namespace pwm
@@ -21,17 +21,17 @@
class pwm_base : private util::noncopyable
{
public:
- typedef std::uint_fast16_t duty_type;
+ using duty_type = std::uint_fast16_t;
- pwm_base(const duty_type resol,
- const duty_type duty = 0U) : resolution(resol),
- counter (0U),
- duty_cycle(duty),
- shadow (duty) { }
+ explicit pwm_base(const duty_type resol,
+ const duty_type duty = duty_type { UINT8_C(0) })
+ : resolution { resol },
+ duty_cycle { duty },
+ shadow { duty } { }
- duty_type get_resolution() const { return resolution; }
+ auto get_resolution() const -> duty_type { return resolution; }
- void set_duty(const duty_type duty)
+ auto set_duty(const duty_type duty) -> void
{
// Set a new duty cycle in the shadow register.
mcal::irq::disable_all();
@@ -41,27 +41,27 @@
mcal::irq::enable_all();
}
- duty_type get_duty() const
+ auto get_duty() const -> duty_type
{
// Retrieve the duty cycle.
mcal::irq::disable_all();
- const volatile std::uint_fast8_t the_duty = duty_cycle;
+ const volatile duty_type the_duty { duty_cycle };
mcal::irq::enable_all();
return the_duty;
}
- virtual void service() = 0;
+ virtual auto service() -> void = 0;
protected:
const duty_type resolution;
- duty_type counter;
duty_type duty_cycle;
duty_type shadow;
+ duty_type counter { };
};
}
}
-#endif // MCAL_PWM_BASE_2017_10_13_H_
+#endif // MCAL_PWM_BASE_2017_10_13_H
diff --git a/examples/chapter09_08/src/mcal/mcal_reg_access_dynamic.h b/examples/chapter09_08/src/mcal/mcal_reg_access_dynamic.h
index 85cd37341..dd121cff7 100644
--- a/examples/chapter09_08/src/mcal/mcal_reg_access_dynamic.h
+++ b/examples/chapter09_08/src/mcal/mcal_reg_access_dynamic.h
@@ -1,37 +1,60 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2013 - 2019.
+// Copyright Christopher Kormanyos 2013 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef MCAL_REG_ACCESS_DYNAMIC_2013_12_13_H_
- #define MCAL_REG_ACCESS_DYNAMIC_2013_12_13_H_
+#ifndef MCAL_REG_ACCESS_DYNAMIC_2013_12_13_H
+ #define MCAL_REG_ACCESS_DYNAMIC_2013_12_13_H
+
+ #if defined(__GNUC__) && (__GNUC__ >= 12)
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Warray-bounds"
+ #endif
namespace mcal
{
namespace reg
{
- template
+ template
struct reg_access_dynamic final
{
- static register_value_type
- reg_get(const register_address_type address) { return *reinterpret_cast(address); }
-
- static void reg_set(const register_address_type address, const register_value_type value) { *reinterpret_cast(address) = value; }
- static void reg_and(const register_address_type address, const register_value_type value) { *reinterpret_cast(address) &= value; }
- static void reg_or (const register_address_type address, const register_value_type value) { *reinterpret_cast(address) |= value; }
- static void reg_not(const register_address_type address, const register_value_type value) { *reinterpret_cast(address) &= register_value_type(~value); }
- static void reg_msk(const register_address_type address, const register_value_type value,
- const register_value_type mask_value) { *reinterpret_cast(address) = register_value_type(register_value_type(reg_get(address) & register_value_type(~mask_value)) | register_value_type(value & mask_value)); }
-
- static void bit_set(const register_address_type address, const register_value_type value) { *reinterpret_cast(address) |= static_cast(1UL << value); }
- static void bit_clr(const register_address_type address, const register_value_type value) { *reinterpret_cast(address) &= static_cast(~static_cast(1UL << value)); }
- static void bit_not(const register_address_type address, const register_value_type value) { *reinterpret_cast(address) ^= static_cast(1UL << value); }
- static bool bit_get(const register_address_type address, const register_value_type value) { return (static_cast(reg_get(address) & static_cast(1UL << value)) != static_cast(0U)); }
+ using register_address_type = RegisterAddressType;
+ using register_value_type = RegisterValueType;
+
+ static auto reg_get(const register_address_type address) -> register_value_type { return *reinterpret_cast(address); }
+ static auto reg_set(const register_address_type address, const register_value_type value) -> void { volatile register_value_type* pa = reinterpret_cast(address); *pa = value; }
+ static auto reg_and(const register_address_type address, const register_value_type value) -> void { volatile register_value_type* pa = reinterpret_cast(address); *pa = static_cast(*pa & value); }
+ static auto reg_or (const register_address_type address, const register_value_type value) -> void { volatile register_value_type* pa = reinterpret_cast(address); *pa = static_cast(*pa | value); }
+ static auto reg_not(const register_address_type address, const register_value_type value) -> void { volatile register_value_type* pa = reinterpret_cast(address); *pa = static_cast(*pa & static_cast(~value)); }
+
+ static auto reg_msk(const register_address_type address,
+ const register_value_type value,
+ const register_value_type mask_value) -> void
+ {
+ volatile register_value_type* pa = reinterpret_cast(address);
+
+ *pa =
+ static_cast
+ (
+ static_cast(reg_get(address) & static_cast(~mask_value))
+ | value
+ );
+ }
+
+ static auto bit_set(const register_address_type address, const register_value_type value) -> void { volatile register_value_type* pa = reinterpret_cast(address); *pa = static_cast(*pa | static_cast(1UL << value)); }
+ static auto bit_clr(const register_address_type address, const register_value_type value) -> void { volatile register_value_type* pa = reinterpret_cast(address); *pa = static_cast(*pa & static_cast(~static_cast(1UL << value))); }
+ static auto bit_not(const register_address_type address, const register_value_type value) -> void { volatile register_value_type* pa = reinterpret_cast(address); *pa = static_cast(*pa ^ static_cast(1UL << value)); }
+ static auto bit_get(const register_address_type address, const register_value_type value) -> bool { return (static_cast(reg_get(address) & static_cast(1UL << value)) != static_cast(0U)); }
};
}
}
-#endif // MCAL_REG_ACCESS_DYNAMIC_2013_12_13_H_
+ #if defined(__GNUC__) && (__GNUC__ >= 12)
+ // -Warray-bounds
+ #pragma GCC diagnostic pop
+ #endif
+
+#endif // MCAL_REG_ACCESS_DYNAMIC_2013_12_13_H
diff --git a/examples/chapter09_08/src/mcal/mcal_reg_access_static.h b/examples/chapter09_08/src/mcal/mcal_reg_access_static.h
index 457ffa60a..be1279e59 100644
--- a/examples/chapter09_08/src/mcal/mcal_reg_access_static.h
+++ b/examples/chapter09_08/src/mcal/mcal_reg_access_static.h
@@ -1,39 +1,60 @@
-///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2019.
+///////////////////////////////////////////////////////////////////////////////
+// Copyright Christopher Kormanyos 2007 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#ifndef MCAL_REG_ACCESS_STATIC_2010_12_01_H_
- #define MCAL_REG_ACCESS_STATIC_2010_12_01_H_
+#ifndef MCAL_REG_ACCESS_STATIC_2010_12_01_H
+ #define MCAL_REG_ACCESS_STATIC_2010_12_01_H
+
+ #if defined(__GNUC__) && (__GNUC__ >= 12)
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Warray-bounds"
+ #endif
namespace mcal
{
namespace reg
{
- template(0)>
+ template(0U)>
struct reg_access_static final
{
- static void reg_set() { *reinterpret_cast(address) = value; }
- static void reg_and() { *reinterpret_cast(address) &= value; }
- static void reg_or () { *reinterpret_cast(address) |= value; }
- static void reg_not() { *reinterpret_cast(address) &= register_value_type(~value); }
- static register_value_type
- reg_get() { return *reinterpret_cast(address); }
+ using register_value_type = RegisterValueType;
+ using register_address_type = RegisterAddressType;
+
+ static auto reg_get() -> register_value_type { volatile register_value_type* pa = reinterpret_cast(address); return *pa; }
+ static auto reg_set() -> void { volatile register_value_type* pa = reinterpret_cast(address); *pa = value; }
+ static auto reg_and() -> void { volatile register_value_type* pa = reinterpret_cast(address); *pa = static_cast(*pa & value); }
+ static auto reg_or () -> void { volatile register_value_type* pa = reinterpret_cast(address); *pa = static_cast(*pa | value); }
+ static auto reg_not() -> void { volatile register_value_type* pa = reinterpret_cast(address); *pa = static_cast(*pa & static_cast(~value)); }
template
- static void reg_msk() { *reinterpret_cast(address) = register_value_type(register_value_type(reg_get() & register_value_type(~mask_value)) | register_value_type(value & mask_value)); }
+ static auto reg_msk() -> void
+ {
+ volatile register_value_type* pa = reinterpret_cast(address);
- static void bit_set() { *reinterpret_cast(address) |= static_cast(1ULL << value); }
- static void bit_clr() { *reinterpret_cast(address) &= static_cast(~static_cast(1ULL << value)); }
- static void bit_not() { *reinterpret_cast(address) ^= static_cast(1ULL << value); }
- static bool bit_get() { return (static_cast(reg_get() & static_cast(1ULL << value)) != static_cast(0U)); }
+ *pa =
+ static_cast
+ (
+ static_cast(reg_get() & static_cast(~mask_value))
+ | value
+ );
+ }
+
+ static auto bit_set() -> void { volatile register_value_type* pa = reinterpret_cast(address); *pa = static_cast(*pa | static_cast(1ULL << value)); }
+ static auto bit_clr() -> void { volatile register_value_type* pa = reinterpret_cast(address); *pa = static_cast(*pa & static_cast(~static_cast(1ULL << value))); }
+ static auto bit_not() -> void { volatile register_value_type* pa = reinterpret_cast(address); *pa = static_cast(*pa ^ static_cast(1ULL << value)); }
+ static auto bit_get() -> bool { return (static_cast(reg_get() & static_cast(1ULL << value)) != static_cast(0U)); }
};
}
}
-#endif // MCAL_REG_ACCESS_STATIC_2010_12_01_H_
+ #if defined(__GNUC__) && (__GNUC__ >= 12)
+ #pragma GCC diagnostic pop
+ #endif
+
+#endif // MCAL_REG_ACCESS_STATIC_2010_12_01_H
diff --git a/examples/chapter09_08/src/mcal/win32/mcal_led_sys_start_interface.cpp b/examples/chapter09_08/src/mcal/win32/mcal_led_sys_start_interface.cpp
index 9fe624c39..d6829533d 100644
--- a/examples/chapter09_08/src/mcal/win32/mcal_led_sys_start_interface.cpp
+++ b/examples/chapter09_08/src/mcal/win32/mcal_led_sys_start_interface.cpp
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2017 - 2018.
+// Copyright Christopher Kormanyos 2017 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -7,9 +7,9 @@
#include
-std::atomic& mcal::led::sys_start_interface::my_exit_pc_api_flag()
+auto mcal::led::sys_start_interface::my_exit_pc_api_flag() -> std::atomic&
{
- static std::atomic my_flag;
+ static std::atomic my_flag { };
return my_flag;
}
diff --git a/examples/chapter09_08/src/mcal/win32/mcal_led_sys_start_interface.h b/examples/chapter09_08/src/mcal/win32/mcal_led_sys_start_interface.h
index 03595a8dc..9c04b3594 100644
--- a/examples/chapter09_08/src/mcal/win32/mcal_led_sys_start_interface.h
+++ b/examples/chapter09_08/src/mcal/win32/mcal_led_sys_start_interface.h
@@ -16,7 +16,7 @@
{
static void my_sys_start();
- static std::atomic& my_exit_pc_api_flag();
+ static auto my_exit_pc_api_flag() -> std::atomic&;
};
} } // namespace mcal::led
diff --git a/examples/chapter09_08/src/mcal_memory/mcal_memory_progmem_array.h b/examples/chapter09_08/src/mcal_memory/mcal_memory_progmem_array.h
index be302e2d9..508c2c1c9 100644
--- a/examples/chapter09_08/src/mcal_memory/mcal_memory_progmem_array.h
+++ b/examples/chapter09_08/src/mcal_memory/mcal_memory_progmem_array.h
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2019 - 2020.
+// Copyright Christopher Kormanyos 2019 - 2025.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -103,7 +103,7 @@
template
bool operator!=(const array& left, const array& right)
{
- return ((left == right) == false);
+ return (!(left == right));
}
template
@@ -115,13 +115,13 @@
template
bool operator>=(const array& left, const array& right)
{
- return ((left < right) == false);
+ return (!(left < right));
}
template
bool operator<=(const array& left, const array& right)
{
- return ((right < left) == false);
+ return (!(right < left));
}
template
diff --git a/examples/chapter09_08/src/sys/start/sys_start.cpp b/examples/chapter09_08/src/sys/start/sys_start.cpp
index e7bd4bb74..82c576600 100644
--- a/examples/chapter09_08/src/sys/start/sys_start.cpp
+++ b/examples/chapter09_08/src/sys/start/sys_start.cpp
@@ -24,7 +24,9 @@ void mcal::led::sys_start_interface::my_sys_start()
}
#if !defined(_MSC_VER)
-extern "C" int main()
+auto main() -> int;
+
+auto main() -> int
{
mcal::led::sys_start_interface::my_sys_start();
}
diff --git a/examples/chapter09_08/src/util/STL/algorithm b/examples/chapter09_08/src/util/STL/algorithm
index c78174fba..b00919672 100644
--- a/examples/chapter09_08/src/util/STL/algorithm
+++ b/examples/chapter09_08/src/util/STL/algorithm
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2007 - 2018.
+// Copyright Christopher Kormanyos 2007 - 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -207,22 +207,20 @@
input_iterator2 first2,
input_iterator2 last2)
{
- while(first1 != last1)
+ for( ; (first1 != last1) && (first2 != last2); static_cast(++first1), static_cast(++first2))
{
- if((first2 == last2) || (*first2 < *first1))
- {
- return false;
- }
- else if(*first1 < *first2)
+ if(*first1 < *first2)
{
return true;
}
- ++first1;
- ++first2;
+ if(*first2 < *first1)
+ {
+ return false;
+ }
}
- return (first2 != last2);
+ return ((first1 == last1) && (first2 != last2));
}
template::value_type;
+
+ *result = result_value_type(*first);
}
return result;
@@ -247,10 +247,12 @@
{
while (first1 != last1)
{
+ using out2_value_type = typename std::iterator_traits::value_type;
+
--last1;
--last2;
- *last2 = *last1;
+ *last2 = out2_value_type(*last1);
}
return last2;
@@ -264,12 +266,12 @@
output_iterator result,
unary_function_type unary_function)
{
- using output_value_type = typename std::iterator_traits::value_type;
-
while(first != last)
{
if(unary_function(*first))
{
+ using output_value_type = typename std::iterator_traits::value_type;
+
*result = output_value_type(*first);
++result;
@@ -287,10 +289,10 @@
forward_iterator last,
const value_type& value)
{
- using forward_value_type = typename std::iterator_traits::value_type;
-
for( ; first != last; ++first)
{
+ using forward_value_type = typename std::iterator_traits::value_type;
+
*first = forward_value_type(value);
}
}
@@ -315,10 +317,10 @@
forward_iterator last,
generator_type generator)
{
- using forward_value_type = typename std::iterator_traits::value_type;
-
while(first != last)
{
+ using forward_value_type = typename std::iterator_traits::value_type;
+
*first = forward_value_type(generator());
++first;
@@ -332,10 +334,10 @@
size_type count,
generator_type generator)
{
- using output_value_type = typename std::iterator_traits::value_type;
-
for(size_type i = size_type(0); i < count; ++i)
{
+ using output_value_type = typename std::iterator_traits::value_type;
+
*first = output_value_type(generator());
++first;
@@ -361,10 +363,10 @@
output_iterator result,
unary_function_type unary_function)
{
- using output_value_type = typename std::iterator_traits::value_type;
-
for( ; first != last; ++first, ++result)
{
+ using output_value_type = typename std::iterator_traits::value_type;
+
*result = output_value_type(unary_function(*first));
}
@@ -381,10 +383,10 @@
output_iterator result,
binary_function_type binary_function)
{
- using output_value_type = typename std::iterator_traits::value_type;
-
for( ; first1 != last1; ++first1, ++first2, ++result)
{
+ using output_value_type = typename std::iterator_traits::value_type;
+
*result = output_value_type(binary_function(*first1, *first2));
}
@@ -421,7 +423,7 @@
{
while(first1 != last1)
{
- if(binary_function(*first1, *first2) == false)
+ if(!binary_function(*first1, *first2))
{
break;
}
@@ -453,7 +455,7 @@
iterator_type last,
unary_function_type unary_function)
{
- while((first != last) && (unary_function(*first) == false))
+ while((first != last) && (!unary_function(*first)))
{
++first;
}
@@ -467,7 +469,7 @@
iterator_type last,
unary_function_type unary_function)
{
- while((first != last) && (unary_function(*first) == false))
+ while((first != last) && (!unary_function(*first)))
{
++first;
}
@@ -765,8 +767,8 @@
}
template
- void swap(swap_type& left,
- swap_type& right)
+ STL_LOCAL_CONSTEXPR_ALGORITHMS void swap(swap_type& left,
+ swap_type& right)
{
if(&left != &right)
{
@@ -777,6 +779,16 @@
}
}
+ template
+ STL_LOCAL_CONSTEXPR_ALGORITHMS void swap(swap_type&& left,
+ swap_type&& right)
+ {
+ const swap_type tmp(left);
+
+ left = right;
+ right = tmp;
+ }
+
template
STL_LOCAL_CONSTEXPR_ALGORITHMS void iter_swap(input_iterator1 left,
@@ -793,9 +805,9 @@
template
- input_iterator2 swap_ranges(input_iterator1 first1,
- input_iterator1 last1,
- input_iterator2 first2)
+ STL_LOCAL_CONSTEXPR_ALGORITHMS input_iterator2 swap_ranges(input_iterator1 first1,
+ input_iterator1 last1,
+ input_iterator2 first2)
{
while(first1 != last1)
{
@@ -810,8 +822,8 @@
template
- void swap(value_type(&left) [N],
- value_type(&right)[N])
+ STL_LOCAL_CONSTEXPR_ALGORITHMS void swap(value_type(&left) [N],
+ value_type(&right)[N])
{
swap_ranges(&left[0U], &left[N], &right[0U]);
}
@@ -824,7 +836,7 @@
{
for( ; ; ++first)
{
- for( ; (first != last) && (unary_function(*first) == true); ++first)
+ for( ; (first != last) && unary_function(*first); ++first)
{
;
}
@@ -834,7 +846,7 @@
break;
}
- for( ; (first != --last) && (unary_function(*last) == false); )
+ for( ; (first != --last) && (!unary_function(*last)); )
{
;
}
diff --git a/examples/chapter09_08/src/util/STL/array b/examples/chapter09_08/src/util/STL/array
index d409196a9..334327a5f 100644
--- a/examples/chapter09_08/src/util/STL/array
+++ b/examples/chapter09_08/src/util/STL/array
@@ -41,8 +41,8 @@
static STL_LOCAL_CONSTEXPR size_type static_size = N;
- STL_LOCAL_CONSTEXPR_ALGORITHMS iterator begin() { return elems; }
- STL_LOCAL_CONSTEXPR_ALGORITHMS iterator end () { return elems + N; }
+ STL_LOCAL_CONSTEXPR iterator begin() { return elems; }
+ STL_LOCAL_CONSTEXPR iterator end () { return elems + N; }
STL_LOCAL_CONSTEXPR const_iterator begin() const { return elems; }
STL_LOCAL_CONSTEXPR const_iterator end () const { return elems + N; }
@@ -50,8 +50,8 @@
STL_LOCAL_CONSTEXPR const_iterator cbegin() const { return elems; }
STL_LOCAL_CONSTEXPR const_iterator cend () const { return elems + N; }
- STL_LOCAL_CONSTEXPR_ALGORITHMS reverse_iterator rbegin() { return reverse_iterator(elems + N); }
- STL_LOCAL_CONSTEXPR_ALGORITHMS reverse_iterator rend () { return reverse_iterator(elems); }
+ STL_LOCAL_CONSTEXPR reverse_iterator rbegin() { return reverse_iterator(elems + N); }
+ STL_LOCAL_CONSTEXPR reverse_iterator rend () { return reverse_iterator(elems); }
STL_LOCAL_CONSTEXPR const_reverse_iterator rbegin() const { return const_reverse_iterator(elems + N); }
STL_LOCAL_CONSTEXPR const_reverse_iterator rend () const { return const_reverse_iterator(elems); }
@@ -59,54 +59,54 @@
STL_LOCAL_CONSTEXPR const_reverse_iterator crbegin() const { return const_reverse_iterator(elems + N); }
STL_LOCAL_CONSTEXPR const_reverse_iterator crend () const { return const_reverse_iterator(elems); }
- STL_LOCAL_CONSTEXPR_ALGORITHMS reference operator[](const size_type i) { return elems[i]; }
- STL_LOCAL_CONSTEXPR const_reference operator[](const size_type i) const { return elems[i]; }
+ STL_LOCAL_CONSTEXPR reference operator[](const size_type i) { return elems[i]; }
+ STL_LOCAL_CONSTEXPR const_reference operator[](const size_type i) const { return elems[i]; }
- STL_LOCAL_CONSTEXPR_ALGORITHMS reference at(const size_type i) { return elems[i]; }
- STL_LOCAL_CONSTEXPR const_reference at(const size_type i) const { return elems[i]; }
+ STL_LOCAL_CONSTEXPR reference at(const size_type i) { return elems[i]; }
+ STL_LOCAL_CONSTEXPR const_reference at(const size_type i) const { return elems[i]; }
- STL_LOCAL_CONSTEXPR_ALGORITHMS reference front() { return elems[0U]; }
- STL_LOCAL_CONSTEXPR const_reference front() const { return elems[0U]; }
+ STL_LOCAL_CONSTEXPR reference front() { return elems[0U]; }
+ STL_LOCAL_CONSTEXPR const_reference front() const { return elems[0U]; }
- STL_LOCAL_CONSTEXPR_ALGORITHMS reference back() { return elems[N - 1U]; }
- STL_LOCAL_CONSTEXPR const_reference back() const { return elems[N - 1U]; }
+ STL_LOCAL_CONSTEXPR reference back() { return elems[N - 1U]; }
+ STL_LOCAL_CONSTEXPR const_reference back() const { return elems[N - 1U]; }
static STL_LOCAL_CONSTEXPR size_type size() { return N; }
static STL_LOCAL_CONSTEXPR bool empty() { return false; }
static STL_LOCAL_CONSTEXPR size_type max_size() { return N; }
template
- STL_LOCAL_CONSTEXPR_ALGORITHMS void swap(array& y)
+ STL_LOCAL_CONSTEXPR void swap(array& y)
{
std::swap_ranges(begin(), end(), y.begin());
}
- STL_LOCAL_CONSTEXPR const_pointer data() const { return elems; }
- STL_LOCAL_CONSTEXPR_ALGORITHMS pointer data() { return elems; }
+ STL_LOCAL_CONSTEXPR const_pointer data() const { return elems; }
+ STL_LOCAL_CONSTEXPR pointer data() { return elems; }
pointer c_array() { return elems; }
template
- STL_LOCAL_CONSTEXPR_ALGORITHMS array& operator=(const array& y)
+ STL_LOCAL_CONSTEXPR array& operator=(const array& y)
{
std::copy(y.begin(), y.end(), begin());
return *this;
}
- STL_LOCAL_CONSTEXPR_ALGORITHMS void assign(const value_type& value)
+ STL_LOCAL_CONSTEXPR void assign(const value_type& value)
{
std::fill_n(elems, N, value);
}
- STL_LOCAL_CONSTEXPR_ALGORITHMS void fill(const value_type& value)
+ STL_LOCAL_CONSTEXPR void fill(const value_type& value)
{
std::fill_n(elems, N, value);
}
};
template
- STL_LOCAL_CONSTEXPR_ALGORITHMS bool operator==(const array& left, const array& right)
+ STL_LOCAL_CONSTEXPR bool operator==(const array& left, const array& right)
{
return std::equal(left.begin(), left.end(), right.begin());
}
@@ -121,31 +121,31 @@
}
template
- STL_LOCAL_CONSTEXPR_ALGORITHMS bool operator!=(const array& left, const array& right)
+ STL_LOCAL_CONSTEXPR bool operator!=(const array& left, const array& right)
{
- return ((left == right) == false);
+ return (!(left == right));
}
template
- STL_LOCAL_CONSTEXPR_ALGORITHMS bool operator>(const array& left, const array& right)
+ STL_LOCAL_CONSTEXPR bool operator>(const array& left, const array& right)
{
return (right < left);
}
template
- STL_LOCAL_CONSTEXPR_ALGORITHMS bool operator>=(const array& left, const array& right)
+ STL_LOCAL_CONSTEXPR bool operator>=(const array& left, const array& right)
{
- return ((left < right) == false);
+ return (!(left < right));
}
template
- STL_LOCAL_CONSTEXPR_ALGORITHMS bool operator<=(const array& left, const array& right)
+ STL_LOCAL_CONSTEXPR bool operator<=(const array& left, const array& right)
{
- return ((right < left) == false);
+ return (!(right < left));
}
template
- STL_LOCAL_CONSTEXPR_ALGORITHMS void swap(array& x, array& y)
+ STL_LOCAL_CONSTEXPR void swap(array& x, array& y)
{
swap_ranges(x.begin(), x.end(), y.begin());
}
diff --git a/examples/chapter09_08/src/util/STL/charconv b/examples/chapter09_08/src/util/STL/charconv
index 6182e2f93..1cb80c4ec 100644
--- a/examples/chapter09_08/src/util/STL/charconv
+++ b/examples/chapter09_08/src/util/STL/charconv
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
-// Copyright Christopher Kormanyos 2021 - 2022.
+// Copyright Christopher Kormanyos 2021 - 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -8,7 +8,9 @@
#ifndef CHARCONV_2021_04_12_
#define CHARCONV_2021_04_12_
- // Implement std::time_t of for compilers that do not yet support it.
+ // Implement some of for compilers that do not yet support it.
+ // At the moment, this contains nothing more than the implementation
+ // of the struct std::to_chars_result.
#include