Coder Social home page Coder Social logo

Comments (5)

0xdead4ead avatar 0xdead4ead commented on May 22, 2024

Sorry to be late with an answer!
Unfortunately, I could not find a suitable solution to saved SFINAE support and returned prvalue from static constructors. I would appreciate if you help me with this. ๐Ÿ™‚

from beasthttp.

saurik avatar saurik commented on May 22, 2024

I am seeing two simple options for your use case here: the first one will require making a new template (as I'm not sure if there's an off-the-shelf definition of this one), but is conceptually direct; the second is "the minimal hack to the thing you are currently doing that will at least make it work".

  1. Given the following definition, you should be able to change decltype(X, std::declval<Y>()) (which returns Y&&) to typename enable_for<X, Y>::type (which returns Y).
template <typename Check_, typename Type_>
struct enable_for {
    typedef Type_ type;
};
  1. I think you also should just be able to wrap your existing decltype(X, std::declval<Y>()) in typename std::decay<...>::type, as that will take the Y&& and decay it to Y.
-> typename std::decay<decltype(
BEASTHTTP_REACTOR_SSL_SESSION_TRY_INVOKE_FLESH_TYPE(std::declval<Router const&>()),
std::declval<context_type>())>::type

from beasthttp.

saurik avatar saurik commented on May 22, 2024

Oh wait! I'm sorry... that first suggestion is wrong as I forgot an extra level of decltype: the correct code would be typename enable_for<decltype(X), Y>::type.

But also, in realizing the underlying mistake I made while suggesting that, it occurred to me that there's a more direct way to use the more built-in STL features.

typename stl::enable_if<(X, true), Y>::type

from beasthttp.

0xdead4ead avatar 0xdead4ead commented on May 22, 2024

ok!
Replace the following macro definitions:

BEASTHTTP_REACTOR_SESSION_TRY_INVOKE_FLESH_TYPE(/*...*/)
BEASTHTTP_REACTOR_SESSION_TRY_INVOKE_FLESH_TYPE_LEGACY(/*...*/)

on this:

template<class Router, class = BEASTHTTP_REACTOR_SESSION_TRY_INVOKE_FLESH_TYPE(/*...*/)>
std::true_type try_invoke_flesh_type_helper(int);

template<class>
std::false_type try_invoke_flesh_type_helper(...);

and:

std::enable_if<decltype(try_invoke_flesh_type_helper<Router const&>(0))::value, context_type>::type

I like a second solution more, need to try it...

from beasthttp.

saurik avatar saurik commented on May 22, 2024

Thanks! I can report that the codebase (at least the parts I'm using) no longer experiences the clang-tidy warning I was reporting.

from beasthttp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.