Skip to content

Commit dff4235

Browse files
committed
Add copy construction support
Explain that each thread should have its own parser object.
1 parent 716e751 commit dff4235

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Note: for current users of *TinyExpr++*, please see the [compatibility advisory]
5353
- Supports C and C++ style comments within math expressions.
5454
- Released under the zlib license - free for nearly any use.
5555
- Easy to use and integrate with your code.
56-
- Thread-safe; parser is in a self-contained object.
56+
- Thread-safe; parser can be constructed as per thread objects.
5757

5858
## Changes from TinyExpr
5959

docs/manual/index.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ It's open-source, free, easy-to-use, and self-contained in a single source and h
4646
- Can be configured to use `double`, `long double`, or [`float`](#te-float) for its calculations.
4747
- Released under the zlib license - free for nearly any use.
4848
- Easy to use and integrate with your code.
49-
- Thread-safe; parser is in a self-contained object.
49+
- Thread-safe; parser can be constructed as per thread objects.

tinyexpr.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,23 @@ class te_parser
246246
/// @private
247247
te_parser() = default;
248248
/// @private
249-
te_parser(const te_parser&) = delete;
249+
te_parser(const te_parser& that)
250+
{
251+
m_customFuncsAndVars = that.m_customFuncsAndVars;
252+
m_unknownSymbolResolve = that.m_unknownSymbolResolve;
253+
m_keepResolvedVarialbes = that.m_keepResolvedVarialbes;
254+
m_decimalSeparator = that.m_decimalSeparator;
255+
m_listSeparator = that.m_listSeparator;
256+
}
250257
/// @private
251-
te_parser& operator=(const te_parser&) = delete;
258+
te_parser& operator=(const te_parser& that)
259+
{
260+
m_customFuncsAndVars = that.m_customFuncsAndVars;
261+
m_unknownSymbolResolve = that.m_unknownSymbolResolve;
262+
m_keepResolvedVarialbes = that.m_keepResolvedVarialbes;
263+
m_decimalSeparator = that.m_decimalSeparator;
264+
m_listSeparator = that.m_listSeparator;
265+
}
252266

253267
/// @private
254268
~te_parser() { te_free(m_compiledExpression); }

0 commit comments

Comments
 (0)