[ create a new paste ] login | about

Link: http://codepad.org/mx41dQZu    [ raw code | fork ]

C++, pasted on Jun 1:
#include <type_traits> 
#include <string>
#include <iostream>

/* 
 * Included from your header */

void 
test (std::string const&)
{
    std::cout << "test (const std::string&)" << std::endl;
}

template <typename T, 
          typename std::enable_if<!(std::is_same<T, std::string&>::value ||
            std::is_convertible<T, std::string>::value), int>::type = 0>
void 
test (T&& x)
{
    std::cout << "test (T&&)" << std::endl;
}

/* 
 * Provided by the user */

struct Bar;

void 
test (Bar const&)
{
    std::cout << "test (const Bar&)" << std::endl;
}

#ifdef BARBAR
struct Bar
{
    operator std::string() { return std::string(); }
};
#endif


int main(int argc, char** argv)
{
    std::string foo;
    Bar& bar = *((Bar*) 0);
    test(foo);
    test(bar);
}


Create a new paste based on this one


Comments: