diff --git a/Modules/Core/Common/include/itkMetaDataObject.hxx b/Modules/Core/Common/include/itkMetaDataObject.hxx index 47c2d548956..27ec13a373b 100644 --- a/Modules/Core/Common/include/itkMetaDataObject.hxx +++ b/Modules/Core/Common/include/itkMetaDataObject.hxx @@ -28,6 +28,7 @@ #ifndef itkMetaDataObject_hxx #define itkMetaDataObject_hxx +#include "itkMetaDataObjectDetail.h" namespace itk { @@ -59,26 +60,6 @@ MetaDataObject::SetMetaDataObjectValue(const MetaDataObjectT Self::Assign(m_MetaDataObjectValue, newValue); } -namespace -{ -template -struct has_Print : std::false_type -{}; - -template -struct has_Print().Print(std::declval()))>> : std::true_type -{}; - -template -struct has_output_operator : std::false_type -{}; - -template -struct has_output_operator() << std::declval())>> - : std::true_type -{}; -} // namespace - template void MetaDataObject::Print(std::ostream & os) const @@ -86,11 +67,11 @@ MetaDataObject::Print(std::ostream & os) const // future c++20 feature // constexpr bool hasPrint = false; requires( const &MetaDataObjectType obj ) { obj.Print(os); }; - if constexpr (has_Print::value) + if constexpr (MetaDataObjectDetail::has_Print::value) { m_MetaDataObjectValue.Print(os); } - else if constexpr (has_output_operator::value) + else if constexpr (MetaDataObjectDetail::has_output_operator::value) { os << m_MetaDataObjectValue; } diff --git a/Modules/Core/Common/include/itkMetaDataObjectDetail.h b/Modules/Core/Common/include/itkMetaDataObjectDetail.h new file mode 100644 index 00000000000..38b140fde03 --- /dev/null +++ b/Modules/Core/Common/include/itkMetaDataObjectDetail.h @@ -0,0 +1,50 @@ +/*========================================================================= + * + * Copyright NumFOCUS + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ + +#ifndef itkMetaDataObjectDetail_h +#define itkMetaDataObjectDetail_h + +#include +#include + +namespace itk +{ + +// Implementation details for MetaDataObject meta programming +namespace MetaDataObjectDetail +{ +template +struct has_Print : std::false_type +{}; + +template +struct has_Print().Print(std::declval()))>> : std::true_type +{}; + +template +struct has_output_operator : std::false_type +{}; + +template +struct has_output_operator() << std::declval())>> + : std::true_type +{}; +} // namespace MetaDataObjectDetail +} // namespace itk + +#endif