Skip to content

Commit fdd6cee

Browse files
lumia431cursoragent
andcommitted
feat: Add compound assignment and increment/decrement operators for reactive variables (#18)
- Add type-safe operator overloads (++, --, +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=) - Restrict operators to VarExpr types only using C++20 concepts - Maintain reactive notifications and batch operation compatibility - Add comprehensive unit tests (10 test cases, 100% pass rate) - Preserve all existing functionality (75/75 tests pass) Enables natural C++ syntax: auto v = var(1); v++; ++v; v += 1; Files modified: - include/reaction/core/concept.h: Added operator type safety concepts - include/reaction/core/react.h: Implemented operator overloads - test/unit/test_operators.cpp: Added comprehensive unit tests Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 11d6930 commit fdd6cee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1769
-372
lines changed

CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ target_include_directories(${PROJECT_NAME} INTERFACE
3838
)
3939

4040
file(GLOB_RECURSE HEADERS_LIST "${CMAKE_CURRENT_SOURCE_DIR}/include/reaction/*.h")
41-
file(GLOB MAIN_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/include/reaction.h")
41+
file(GLOB MAIN_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/include/reaction/reaction.h")
4242
foreach(header_file ${HEADERS_LIST} ${MAIN_HEADER})
4343
target_sources(${PROJECT_NAME} INTERFACE
4444
$<BUILD_INTERFACE:${header_file}>
@@ -105,4 +105,14 @@ install(
105105
EXPORT ${PROJECT_NAME}Targets
106106
NAMESPACE ${PROJECT_NAME}::
107107
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
108-
)
108+
)
109+
110+
if(NOT TARGET uninstall)
111+
configure_file(
112+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
113+
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
114+
IMMEDIATE @ONLY)
115+
116+
add_custom_target(uninstall
117+
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
118+
endif()

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ After installation, you can include and link against reaction in your own CMake-
102102
find_package(reaction REQUIRED)
103103
```
104104

105+
### Uninstall
106+
107+
To uninstall the framework:
108+
109+
```bash
110+
cmake --build build/ --target uninstall
111+
```
112+
105113
If you want to run example or test units:
106114

107115
```bash
@@ -112,7 +120,7 @@ cmake --build build/
112120
## 🚀 Quick Start
113121

114122
```cpp
115-
#include <reaction.h>
123+
#include <reaction/reaction.h>
116124
#include <iostream>
117125
#include <iomanip>
118126
#include <cmath>

README.zh-CN.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ cmake --install build/ --prefix /your/install/path
102102
find_package(reaction REQUIRED)
103103
```
104104

105+
### 卸载
106+
107+
要卸载框架:
108+
109+
```bash
110+
cmake --build build/ --target uninstall
111+
```
112+
105113
如需运行示例或测试单元:
106114

107115
```bash

benchmark/bench_cache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "reaction.h"
1+
#include "reaction/reaction.h"
22
#include <chrono>
33
#include <iostream>
44
#include <vector>

benchmark/bench_comparison.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "reaction.h"
1+
#include "reaction/reaction.h"
22
#include "rxcpp/rx.hpp"
33
#include <benchmark/benchmark.h>
44
#include <chrono>

benchmark/bench_multi_thread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "reaction.h"
1+
#include "reaction/reaction.h"
22
#include <benchmark/benchmark.h>
33
#include <thread>
44
#include <vector>

cmake/cmake_uninstall.cmake.in

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
2+
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
3+
endif()
4+
5+
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
6+
string(REGEX REPLACE "\n" ";" files "${files}")
7+
foreach(file ${files})
8+
message(STATUS "Uninstalling: $ENV{DESTDIR}${file}")
9+
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
10+
exec_program(
11+
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
12+
OUTPUT_VARIABLE rm_out
13+
RETURN_VALUE rm_retval
14+
)
15+
if(NOT "${rm_retval}" STREQUAL 0)
16+
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
17+
endif()
18+
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
19+
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
20+
endif()
21+
endforeach()

example/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ file(GLOB EXAMPLE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
22
foreach(example_file ${EXAMPLE_SOURCES})
33
get_filename_component(example_name ${example_file} NAME_WE)
44
add_executable(${example_name} ${example_file})
5-
target_link_libraries(${example_name} PRIVATE ${PROJECT_NAME})
5+
target_link_libraries(${example_name} PRIVATE ${PROJECT_NAME} -pthread)
66
endforeach()

example/basic_example.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Use case: Stock price tracking with automatic profit/loss calculation
1919
*/
2020

21-
#include <reaction.h>
21+
#include <reaction/reaction.h>
2222
#include <cmath>
2323
#include <iomanip>
2424
#include <iostream>

example/batch_example.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <cmath>
99
#include <iomanip>
1010
#include <iostream>
11-
#include <reaction.h>
11+
#include <reaction/reaction.h>
1212
#include <string>
1313
#include <vector>
1414

0 commit comments

Comments
 (0)