\hypertarget{_w_1_2_work_2_software_2_libraries_2utl_2include_2utl_2meta_2detection_8h-example}{}\section{W\+:/\+Work/\+Software/\+Libraries/utl/include/utl/meta/detection.\+h}
detection interface

Checks if Op$<$\+Args...$>$ is a valid expression without evaluating it.


\begin{DoxyTemplParams}{Template Parameters}
{\em Op} & a meta-\/callback function to pass Args... \\
\hline
{\em Args...} & types to pass to Op for checking \\
\hline
\end{DoxyTemplParams}
\begin{DoxyReturn}{Returns}
status of the operation \mbox{[}bool\+\_\+\mbox{]} \begin{DoxyItemize}
\item true\+\_\+ if Op$<$\+Args...$>$ is valid expression \item false\+\_\+ if Op$<$\+Args...$>$ is not valid\end{DoxyItemize}

\begin{DoxyCode}
\textcolor{comment}{// archetypal alias for a copy assignment operation}
\textcolor{keyword}{template}< \textcolor{keyword}{class} T > \textcolor{keyword}{using} copy\_assign\_t = decltype( declval<T&>() = declval<T const &>() );

\textcolor{keyword}{template}< \textcolor{keyword}{class} T > \textcolor{keyword}{using} is\_copy\_assignable = is\_detected< copy\_assign\_t, T >;
\end{DoxyCode}

\end{DoxyReturn}

\begin{DoxyCodeInclude}

\textcolor{preprocessor}{#ifndef \_\_utl\_meta\_detection\_h\_\_}
\textcolor{preprocessor}{#define \_\_utl\_meta\_detection\_h\_\_}

\textcolor{preprocessor}{#include <\mbox{\hyperlink{impl_8h}{utl/core/impl.h}}>}
\textcolor{preprocessor}{#include <\mbox{\hyperlink{operations_8h}{utl/meta/operations.h}}>}
\textcolor{preprocessor}{#include <type\_traits>}


\textcolor{keyword}{namespace }\mbox{\hyperlink{namespaceutl}{utl}} \{
\textcolor{keyword}{namespace }meta \{

\textcolor{preprocessor}{   #if defined(UTL\_WORKAROUND\_CWG\_1558)}
      \textcolor{keyword}{template}<\textcolor{keyword}{typename}... \_Ts>
      \textcolor{keyword}{struct }\mbox{\hyperlink{group__detection_gac16d50de47cf57734433e9ea636522c5}{void\_}} \{
         \textcolor{keyword}{using} type = void;
      \};
      \textcolor{keyword}{template}<\textcolor{keyword}{typename}... \_Ts>
      \textcolor{keyword}{using} \mbox{\hyperlink{group__detection_gae7373c997420d16cf37e542eb3cfa3ad}{void\_t}} = \mbox{\hyperlink{namespaceutl_1_1meta_aa5a37adba244ff4286f994111c4c02ea}{eval}}<\mbox{\hyperlink{group__detection_gac16d50de47cf57734433e9ea636522c5}{void\_}}<\_Ts...>>;
\textcolor{preprocessor}{   #else}
      \textcolor{keyword}{template} <\textcolor{keyword}{typename}...> \textcolor{keyword}{using} \mbox{\hyperlink{group__detection_gac16d50de47cf57734433e9ea636522c5}{void\_}}  = void;
      \textcolor{keyword}{template} <\textcolor{keyword}{typename}...> \textcolor{keyword}{using} \mbox{\hyperlink{group__detection_gae7373c997420d16cf37e542eb3cfa3ad}{void\_t}} = void;
\textcolor{preprocessor}{   #endif}

   \textcolor{keyword}{struct }nat\_ \{
      nat\_()  = \textcolor{keyword}{delete};
      ~nat\_() = \textcolor{keyword}{delete};
      nat\_(nat\_ \textcolor{keyword}{const}&)         = \textcolor{keyword}{delete};
      \textcolor{keywordtype}{void} operator = (nat\_ \textcolor{keyword}{const}&) = \textcolor{keyword}{delete};
   \};

   \textcolor{keyword}{namespace }detail \{
      \textcolor{keyword}{template} <\textcolor{keyword}{typename} Default,
                \textcolor{keyword}{typename} AlwaysVoid,
                \textcolor{keyword}{template}<\textcolor{keyword}{typename}...> \textcolor{keyword}{class }Op, \textcolor{keyword}{typename}... Args>
      \textcolor{keyword}{struct }detector \{
         \textcolor{keyword}{using} detected = \mbox{\hyperlink{namespaceutl_1_1meta_a55511dbaa0adb605ce22dcec11f8d22d}{false\_}};
         \textcolor{keyword}{using} type = Default;
      \};

      \textcolor{keyword}{template} <\textcolor{keyword}{typename} Default,
                \textcolor{keyword}{template}<\textcolor{keyword}{typename}...> \textcolor{keyword}{class }Op, \textcolor{keyword}{typename}... Args>
      \textcolor{keyword}{struct }detector <Default, \mbox{\hyperlink{group__detection_gae7373c997420d16cf37e542eb3cfa3ad}{void\_t}}<Op<Args...>>, Op, Args...> \{
         \textcolor{keyword}{using} detected = \mbox{\hyperlink{namespaceutl_1_1meta_ae9a5a8fbe8202785f059935af219fb97}{true\_}};
         \textcolor{keyword}{using} type = Op<Args...>;
      \};

      \textcolor{keyword}{template} <\textcolor{keyword}{typename} Default,
                \textcolor{keyword}{template}<\textcolor{keyword}{typename}...> \textcolor{keyword}{class }Op, \textcolor{keyword}{typename}... Args>
      \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_1_1detail_a835827cb3116483228d6f7f774b68970}{detected\_or}} = detector<Default, void, Op, Args...>;
   \} \textcolor{comment}{// namespace detail}
\textcolor{comment}{}

   \textcolor{keyword}{template} <\textcolor{keyword}{template}<\textcolor{keyword}{typename}...> \textcolor{keyword}{class }Op, \textcolor{keyword}{typename}... Args>
   \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_a5329219a9d2f195421a78d8e07873507}{is\_detected}} = \textcolor{keyword}{typename} detail::detector<nat\_, void, Op, Args...>::detected;

   \textcolor{keyword}{template}< \textcolor{keyword}{template}<\textcolor{keyword}{typename}...> \textcolor{keyword}{class }Op, \textcolor{keyword}{typename}... Args>
   constexpr \textcolor{keywordtype}{bool} \mbox{\hyperlink{namespaceutl_1_1meta_a4f3184ccb8e8ba2a78e2d2e83a0b9885}{is\_detected\_v}} = \mbox{\hyperlink{namespaceutl_1_1meta_a5329219a9d2f195421a78d8e07873507}{is\_detected}}<Op, Args...>::value;

   \textcolor{keyword}{template} <\textcolor{keyword}{template}<\textcolor{keyword}{typename}...> \textcolor{keyword}{class }Op, \textcolor{keyword}{typename}... Args>
   \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_aa654a286b3bc8e6d8116ee1f57087110}{detected\_t}} = \mbox{\hyperlink{namespaceutl_1_1meta_aa5a37adba244ff4286f994111c4c02ea}{eval}} <
      detail::detector<nat\_, void, Op, Args...>
   >;

   \textcolor{keyword}{template} <\textcolor{keyword}{typename} Default,
             \textcolor{keyword}{template}<\textcolor{keyword}{typename}...> \textcolor{keyword}{class }Op, \textcolor{keyword}{typename}... Args>
   \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_a8fd055bc6c6c3b1d551e9605aa35644c}{detected\_or\_t}} = \mbox{\hyperlink{namespaceutl_1_1meta_aa5a37adba244ff4286f994111c4c02ea}{eval}} <
      \mbox{\hyperlink{namespaceutl_1_1meta_1_1detail_a835827cb3116483228d6f7f774b68970}{detail::detected\_or}}<Default, Op, Args...>
   >;

   \textcolor{keyword}{template} <\textcolor{keyword}{typename} Expected,
             \textcolor{keyword}{template}<\textcolor{keyword}{typename}...> \textcolor{keyword}{class }Op, \textcolor{keyword}{typename}... Args >
   \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_ad5224ef66e8f40efaaf3ad3d605dd629}{is\_detected\_exact}} = \mbox{\hyperlink{namespaceutl_1_1meta_aa5a37adba244ff4286f994111c4c02ea}{eval}} <
      same\_<Expected, \mbox{\hyperlink{namespaceutl_1_1meta_aa654a286b3bc8e6d8116ee1f57087110}{detected\_t}}<Op, Args...>>
   >;

   \textcolor{keyword}{template} <\textcolor{keyword}{typename} Expected,
             \textcolor{keyword}{template}<\textcolor{keyword}{typename}...> \textcolor{keyword}{class }Op, \textcolor{keyword}{typename}... Args >
   constexpr \textcolor{keywordtype}{bool} \mbox{\hyperlink{namespaceutl_1_1meta_a960827a1d72083a511f8ea4ccc8beceb}{is\_detected\_exact\_v}} = \mbox{\hyperlink{namespaceutl_1_1meta_ad5224ef66e8f40efaaf3ad3d605dd629}{is\_detected\_exact}}< Expected, Op
      , Args...>::value;

   \textcolor{keyword}{template} <\textcolor{keyword}{typename} To,
             \textcolor{keyword}{template}<\textcolor{keyword}{typename}...> \textcolor{keyword}{class }Op, \textcolor{keyword}{typename}... Args >
   \textcolor{keyword}{using} \mbox{\hyperlink{namespaceutl_1_1meta_afa24702fa15a1d0a8a05761c54b79def}{is\_detected\_convertible}} = \mbox{\hyperlink{namespaceutl_1_1meta_aa5a37adba244ff4286f994111c4c02ea}{eval}} <
      std::is\_convertible< \mbox{\hyperlink{namespaceutl_1_1meta_aa654a286b3bc8e6d8116ee1f57087110}{detected\_t}}<Op, Args...>, To >
   >;

   \textcolor{keyword}{template} <\textcolor{keyword}{typename} To,
             \textcolor{keyword}{template}<\textcolor{keyword}{typename}...> \textcolor{keyword}{class }Op, \textcolor{keyword}{typename}... Args >
   constexpr \textcolor{keywordtype}{bool} \mbox{\hyperlink{namespaceutl_1_1meta_acba521b528e775be4b37d2e481e0f138}{is\_detected\_convertible\_v}} =
      \mbox{\hyperlink{namespaceutl_1_1meta_afa24702fa15a1d0a8a05761c54b79def}{is\_detected\_convertible}}<To, Op, Args...>::value;

\}\}

\textcolor{preprocessor}{#endif }\textcolor{comment}{/* \_\_utl\_meta\_detection\_h\_\_ */}\textcolor{preprocessor}{}
\end{DoxyCodeInclude}
 