I sometimes do something a little more evil
\documentclass[a4paper]{memoir}
\usepackage{mathtools}
\DeclarePairedDelimiterX\Set[2]{\lbrace}{\rbrace}%
{ #1 \,\delimsize| \,\mathopen{} #2 }
\begin{document}
\[
\Set*{ x }{ x>0 }
\]
\end{document}
and thus hide the symbol inside the construction. Both a starred and non-starred \Set
is created with \Set*
autoscaling braces and vertical line is used.
Update August 2014: I no longer recommend a two argument solution, but rather this as I feel it gives an interface much closer to the mathematical meaning
\documentclass[a4paper]{memoir}
\usepackage{mathtools}
\providecommand\given{} % so it exists
\newcommand\SetSymbol[1][]{
\nonscript\,#1\vert \allowbreak \nonscript\,\mathopen{}}
\DeclarePairedDelimiterX\Set[1]{\lbrace}{\rbrace}%
{ \renewcommand\given{\SetSymbol[\delimsize]} #1 }
\begin{document}
\[
\Set*{ x \given x>0 }
\]
\end{document}
BTW: notice the added \mathopen{}
withput it \Set{ X \given -a < x < a}
would give us the wrong -a
(a subtraction minus, not a sign minus)
Update March 2015: Moved the \allowbreak
in front of the proceeding inserted space. Then that space disappears if a line break happens.