I want to define a restriction operator \restrict{f}{X} which is capable of resizing in the style of mathtools's \DeclarePairedDelimiter options. For example:
\restrict*{f}{X}should resize automatically\restrict[\Big]{f}{X}should provide a large vertical bar regardless of whatfis- &c.
The MWE I currently have throws an error:
\documentclass{article}
\usepackage{mathtools}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}
\DeclarePairedDelimiterXPP{\restrict}[2]{}{}\rvert
{\IfNoValueTF{#2}{}{_{#2}}}
{#1}
\begin{document}
\begin{equation}
\restrict{f}{X}
= \restrict*{\frac{f}{1}}{X}
\end{equation}
\end{document}
When running this, I get an appropriate output, but the error:
Missing delimiter (. inserted).
This makes sense, since the left delimiter I provided was the empty token {}. However, if I replace it with {.}, then for the nonstarred \restrict, a period is introduced in the typesetting which I do not wish for.
Is there a way to communicate to \DeclarePairedDelimiter that I want an empty delimiter, or must I go the route of error-surpressing?

#3\mathclose#2|or#3\mathclose{#2|}perhaps be better, or at least more correct? Then the spacing would behave the same way as in the auto-scaled case (where you use\mrightrather than\right). – Gaussler May 05 '23 at 08:56#3#2,#3\mathclose#2, and#3\mathclose{#2|}. Does this affect how it displays in different situations (like subscripts)? – Phrohlych May 05 '23 at 19:37