#include <iostream>
#include <stack>
#include <algorithm>

template < typename T, typename C >
bool is_in_stack( const std::stack<T,C>& stk, const T& v )
{
    struct checker : private std::stack<T,C>
    {
        static bool is_in_stack( const std::stack<T,C>& stk, const T& v )
        {
            // get a reference to the underlying sequence container
            const auto& seq = static_cast< const checker& >(stk).c ;

            // check for the element in it
            return std::find( seq.begin(), seq.end(), v ) != seq.end() ;
        }
    };
    return checker::is_in_stack( stk, v ) ;
}

int main()
{
    // move constructor
    std::stack<int> stk( std::stack<int>::container_type { 1, 3, 5, 7, 9 } ) ;

    std::cout << std::boolalpha << is_in_stack( stk, 7 ) << '\n' // true
                                << is_in_stack( stk, 4 ) << '\n' ; // false
}
