From e9eb0323c5c00a358bbda4cb453c95bae68657d5 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 8 Dec 2020 14:36:26 -0800 Subject: [PATCH] Issue #16 --- include/boost/leaf.hpp | 2 -- include/boost/leaf/error.hpp | 2 -- test/BOOST_LEAF_AUTO_test.cpp | 18 +++++++++++++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/include/boost/leaf.hpp b/include/boost/leaf.hpp index fa59d66..b56aa08 100644 --- a/include/boost/leaf.hpp +++ b/include/boost/leaf.hpp @@ -1002,7 +1002,6 @@ namespace boost { namespace leaf { #define BOOST_LEAF_TMP BOOST_LEAF_TOKEN_PASTE2(boost_leaf_tmp_, __LINE__) #define BOOST_LEAF_ASSIGN(v,r)\ - static_assert(::boost::leaf::is_result_type::type>::value, "The BOOST_LEAF_ASSIGN macro requires a result type as the second argument");\ auto && BOOST_LEAF_TMP = r;\ if( !BOOST_LEAF_TMP )\ return BOOST_LEAF_TMP.error();\ @@ -1012,7 +1011,6 @@ namespace boost { namespace leaf { BOOST_LEAF_ASSIGN(auto v, r) #define BOOST_LEAF_CHECK(r)\ - static_assert(::boost::leaf::is_result_type::type>::value, "BOOST_LEAF_CHECK requires a result type");\ auto && BOOST_LEAF_TMP = r;\ if( BOOST_LEAF_TMP )\ ;\ diff --git a/include/boost/leaf/error.hpp b/include/boost/leaf/error.hpp index c6cde7d..9d18e08 100644 --- a/include/boost/leaf/error.hpp +++ b/include/boost/leaf/error.hpp @@ -33,7 +33,6 @@ #define BOOST_LEAF_TMP BOOST_LEAF_TOKEN_PASTE2(boost_leaf_tmp_, __LINE__) #define BOOST_LEAF_ASSIGN(v,r)\ - static_assert(::boost::leaf::is_result_type::type>::value, "The BOOST_LEAF_ASSIGN macro requires a result type as the second argument");\ auto && BOOST_LEAF_TMP = r;\ if( !BOOST_LEAF_TMP )\ return BOOST_LEAF_TMP.error();\ @@ -43,7 +42,6 @@ BOOST_LEAF_ASSIGN(auto v, r) #define BOOST_LEAF_CHECK(r)\ - static_assert(::boost::leaf::is_result_type::type>::value, "BOOST_LEAF_CHECK requires a result type");\ auto && BOOST_LEAF_TMP = r;\ if( BOOST_LEAF_TMP )\ ;\ diff --git a/test/BOOST_LEAF_AUTO_test.cpp b/test/BOOST_LEAF_AUTO_test.cpp index 21e14a5..bda6072 100644 --- a/test/BOOST_LEAF_AUTO_test.cpp +++ b/test/BOOST_LEAF_AUTO_test.cpp @@ -34,10 +34,26 @@ leaf::result f2() #endif } +template +leaf::result f2_lambda( Lambda ) +{ + BOOST_LEAF_AUTO(a, f1()); +#if BOOST_WORKAROUND( BOOST_GCC, < 50000 ) || BOOST_WORKAROUND( BOOST_CLANG, <= 30800 ) + return std::move(a); // Older compilers are confused, but... +#else + return a; // ...this doesn't need to be return std::move(a); +#endif +} + leaf::result f3() { BOOST_LEAF_AUTO(a, f2()); - BOOST_LEAF_AUTO(b, f2()); // Invoking the macro twice in the same scope, testing the temp name generation + + // Invoking the macro twice in the same scope, testing the temp name + // generation. Also making sure we can pass a lambda (See + // https://github.com/boostorg/leaf/issues/16). + BOOST_LEAF_AUTO(b, f2_lambda([]{})); + return value { a.x + b.x }; }