/* Allows the test kernel to be compiled standalone (C) 2016-2020 Niall Douglas (6 commits) Created: May 2016 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 in the accompanying file Licence.txt or at http://www.apache.org/licenses/LICENSE-2.0 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. Distributed under the Boost Software License, Version 1.0. (See accompanying file Licence.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ #ifndef LLFIO_TEST_KERNEL_DECL_HPP #define LLFIO_TEST_KERNEL_DECL_HPP #define _CRT_SECURE_NO_WARNINGS 1 #ifdef BOOST_KERNELTEST_PLEASE_INLINE_TEST_KERNELS // We have been included as part of an inline test suite #define LLFIO_TEST_KERNEL_DECL inline #else // We are standalone #include "../include/llfio/llfio.hpp" #define LLFIO_TEST_KERNEL_DECL extern inline QUICKCPPLIB_SYMBOL_EXPORT #endif #if LLFIO_EXPERIMENTAL_STATUS_CODE #define KERNELTEST_EXPERIMENTAL_STATUS_CODE 1 #include "outcome/experimental/status-code/include/iostream_support.hpp" // Used for initialiser list stored results as the erased form is move-only template using il_result = OUTCOME_V2_NAMESPACE::experimental::status_result; #else template using il_result = LLFIO_V2_NAMESPACE::result; #endif #include "kerneltest/kerneltest.hpp" #if 0 // Tell KernelTest's outcome how to grok LLFIO's result OUTCOME_V2_NAMESPACE_BEGIN namespace convert { // Provide custom ValueOrError conversion from llfio::result into kerneltest::result template struct value_or_error, LLFIO_V2_NAMESPACE::result> { static constexpr bool enable_result_inputs = true; static constexpr bool enable_outcome_inputs = true; template , std::decay_t>::value // && std::is_constructible::value>> // constexpr KERNELTEST_V1_NAMESPACE::result operator()(X &&src) { // Forward exactly return src.has_value() ? // KERNELTEST_V1_NAMESPACE::result{std::forward(src).value()} // : KERNELTEST_V1_NAMESPACE::result{make_error_code(std::forward(src).error())}; } }; // Provide custom ValueOrError conversion from llfio::result into kerneltest::outcome template struct value_or_error, LLFIO_V2_NAMESPACE::result> { static constexpr bool enable_result_inputs = true; static constexpr bool enable_outcome_inputs = true; template , std::decay_t>::value // && std::is_constructible::value>> // constexpr KERNELTEST_V1_NAMESPACE::outcome operator()(X &&src) { // Forward exactly return src.has_value() ? // KERNELTEST_V1_NAMESPACE::outcome{std::forward(src).value()} // : KERNELTEST_V1_NAMESPACE::outcome{make_error_code(std::forward(src).error())}; } }; } OUTCOME_V2_NAMESPACE_END static_assert(std::is_constructible, LLFIO_V2_NAMESPACE::result>::value, "kerneltest::result is not constructible from llfio::result!"); static_assert(std::is_constructible, LLFIO_V2_NAMESPACE::result>::value, "kerneltest::outcome is not constructible from llfio::result!"); #endif #endif // namespace