Skip to content

Commit

Permalink
Add copy construction support
Browse files Browse the repository at this point in the history
Explain that each thread should have its own parser object.
  • Loading branch information
Blake-Madden committed May 28, 2024
1 parent 716e751 commit dff4235
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Note: for current users of *TinyExpr++*, please see the [compatibility advisory]
- Supports C and C++ style comments within math expressions.
- Released under the zlib license - free for nearly any use.
- Easy to use and integrate with your code.
- Thread-safe; parser is in a self-contained object.
- Thread-safe; parser can be constructed as per thread objects.

## Changes from TinyExpr

Expand Down
2 changes: 1 addition & 1 deletion docs/manual/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ It's open-source, free, easy-to-use, and self-contained in a single source and h
- Can be configured to use `double`, `long double`, or [`float`](#te-float) for its calculations.
- Released under the zlib license - free for nearly any use.
- Easy to use and integrate with your code.
- Thread-safe; parser is in a self-contained object.
- Thread-safe; parser can be constructed as per thread objects.
18 changes: 16 additions & 2 deletions tinyexpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,23 @@ class te_parser
/// @private
te_parser() = default;
/// @private
te_parser(const te_parser&) = delete;
te_parser(const te_parser& that)
{
m_customFuncsAndVars = that.m_customFuncsAndVars;
m_unknownSymbolResolve = that.m_unknownSymbolResolve;
m_keepResolvedVarialbes = that.m_keepResolvedVarialbes;
m_decimalSeparator = that.m_decimalSeparator;
m_listSeparator = that.m_listSeparator;
}
/// @private
te_parser& operator=(const te_parser&) = delete;
te_parser& operator=(const te_parser& that)
{
m_customFuncsAndVars = that.m_customFuncsAndVars;
m_unknownSymbolResolve = that.m_unknownSymbolResolve;
m_keepResolvedVarialbes = that.m_keepResolvedVarialbes;
m_decimalSeparator = that.m_decimalSeparator;
m_listSeparator = that.m_listSeparator;
}

/// @private
~te_parser() { te_free(m_compiledExpression); }
Expand Down

0 comments on commit dff4235

Please sign in to comment.