[logical.operations] # 22 General utilities library [[utilities]](./#utilities) ## 22.10 Function objects [[function.objects]](function.objects#logical.operations) ### 22.10.10 Logical operations [logical.operations] #### [22.10.10.1](#general) General [[logical.operations.general]](logical.operations.general) [1](#general-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12796) The library provides basic function object classes for all of the logical operators in the language ([[expr.log.and]](expr.log.and "7.6.14 Logical AND operator"), [[expr.log.or]](expr.log.or "7.6.15 Logical OR operator"), [[expr.unary.op]](expr.unary.op "7.6.2.2 Unary operators"))[.](#general-1.sentence-1) #### [22.10.10.2](#and) Class template logical_and [[logical.operations.and]](logical.operations.and) [🔗](#lib:logical_and) `template struct logical_and { constexpr bool operator()(const T& x, const T& y) const; }; ` [🔗](#lib:operator(),logical_and) `constexpr bool operator()(const T& x, const T& y) const; ` [1](#and-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12815) *Returns*: x && y[.](#and-1.sentence-1) [🔗](#lib:logical_and%3c%3e) `template<> struct logical_and { template constexpr auto operator()(T&& t, U&& u) const -> decltype(std::forward(t) && std::forward(u)); using is_transparent = unspecified; }; ` [🔗](#lib:operator(),logical_and%3c%3e) `template constexpr auto operator()(T&& t, U&& u) const -> decltype(std::forward(t) && std::forward(u)); ` [2](#and-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12837) *Returns*: std​::​forward(t) && std​::​forward(u)[.](#and-2.sentence-1) #### [22.10.10.3](#or) Class template logical_or [[logical.operations.or]](logical.operations.or) [🔗](#lib:logical_or) `template struct logical_or { constexpr bool operator()(const T& x, const T& y) const; }; ` [🔗](#lib:operator(),logical_or) `constexpr bool operator()(const T& x, const T& y) const; ` [1](#or-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12857) *Returns*: x || y[.](#or-1.sentence-1) [🔗](#lib:logical_or%3c%3e) `template<> struct logical_or { template constexpr auto operator()(T&& t, U&& u) const -> decltype(std::forward(t) || std::forward(u)); using is_transparent = unspecified; }; ` [🔗](#lib:operator(),logical_or%3c%3e) `template constexpr auto operator()(T&& t, U&& u) const -> decltype(std::forward(t) || std::forward(u)); ` [2](#or-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12879) *Returns*: std​::​forward(t) || std​::​forward(u)[.](#or-2.sentence-1) #### [22.10.10.4](#not) Class template logical_not [[logical.operations.not]](logical.operations.not) [🔗](#lib:logical_not) `template struct logical_not { constexpr bool operator()(const T& x) const; }; ` [🔗](#lib:operator(),logical_not) `constexpr bool operator()(const T& x) const; ` [1](#not-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12899) *Returns*: !x[.](#not-1.sentence-1) [🔗](#lib:logical_not%3c%3e) `template<> struct logical_not { template constexpr auto operator()(T&& t) const -> decltype(!std::forward(t)); using is_transparent = unspecified; }; ` [🔗](#lib:operator(),logical_not%3c%3e) `template constexpr auto operator()(T&& t) const -> decltype(!std::forward(t)); ` [2](#not-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12921) *Returns*: !std​::​forward(t)[.](#not-2.sentence-1)