this is a challenge to techno"boss"

ryuken

ryuken

Fuchsia
Joined
Jun 10, 2024
Posts
11,670
Reputation
25,387
this is a challenge to the guy who calls himself technoboss i never saw you actually talk about programming or tech so how do you call yourself techno"boss"

the challenge is:
i want you to tell me the Lambda Functions, Type Traits and Templates and SFINAE of the following c++ code


#include <iostream>
#include <type_traits>

// Primary template for the trait, by default it returns false
template <typename, typename T>
struct has_to_string : std::false_type {};

// Specialization of the trait where substitution will succeed if the class T has a method `std::string to_string() const`
template <typename C>
struct has_to_string<C, std::string(C::*)() const> : std::true_type {};

// Helper template to deduce the function signature
template <typename C>
constexpr bool has_to_string_v = has_to_string<C, decltype(&C::to_string)>::value;

// Example classes
struct A {
std::string to_string() const { return "Class A"; }
};

struct B {
int to_string() const { return 42; } // Different return type, won't match std::string
};

struct C {
void foo() const {} // No `to_string` method at all
};

// Function that uses SFINAE to conditionally compile based on whether the class has a `to_string` method
template <typename T>
typename std::enable_if<has_to_string_v<T>, void>::type
print_to_string(const T& obj) {
std::cout << obj.to_string() << std::endl;
}

template <typename T>
typename std::enable_if<!has_to_string_v<T>, void>::type
print_to_string(const T&) {
std::cout << "No to_string method available" << std::endl;
}

int main() {
A a;
B b;
C c;

print_to_string(a); // Prints "Class A"
print_to_string(b); // Prints "No to_string method available"
print_to_string(c); // Prints "No to_string method available"

return 0;
}

the punishment if you fail: we will call you lil techno for a week

if you succeeded: i will make my banner whatever you want and i will make an apology thread and give my loyalty to you to the rest of my life
 
  • So Sad
  • +1
  • JFL
Reactions: Deleted member 67738, Deleted member 74849 and Deleted member 45794
@N9wiff•˚₊‧⋆. @itzyaboyJJ @Darkeningstar @Willmogulater
 
  • +1
  • Woah
  • JFL
Reactions: Deleted member 67738, Deleted member 74849 and Deleted member 45794
@Gaygymmaxx @Putin @cromagnon
 
  • So Sad
Reactions: Deleted member 45794
@TechnoBoss revealed to me in PM's that he is classified as "illiterate" 😢
 
  • +1
  • JFL
Reactions: Clqs, Deleted member 67738 and ryuken
He probably likes techo music because hes edgy and shiet
 
  • JFL
Reactions: Deleted member 74849, Deleted member 45794, TechnoBoss and 1 other person
this is a challenge to the guy who calls himself technoboss i never saw you actually talk about programming or tech so how do you call yourself techno"boss"

the challenge is:
i want you to tell me the Lambda Functions, Type Traits and Templates and SFINAE of the following c++ code


#include <iostream>
#include <type_traits>

// Primary template for the trait, by default it returns false
template <typename, typename T>
struct has_to_string : std::false_type {};

// Specialization of the trait where substitution will succeed if the class T has a method `std::string to_string() const`
template <typename C>
struct has_to_string<C, std::string(C::*)() const> : std::true_type {};

// Helper template to deduce the function signature
template <typename C>
constexpr bool has_to_string_v = has_to_string<C, decltype(&C::to_string)>::value;

// Example classes
struct A {
std::string to_string() const { return "Class A"; }
};

struct B {
int to_string() const { return 42; } // Different return type, won't match std::string
};

struct C {
void foo() const {} // No `to_string` method at all
};

// Function that uses SFINAE to conditionally compile based on whether the class has a `to_string` method
template <typename T>
typename std::enable_if<has_to_string_v<T>, void>::type
print_to_string(const T& obj) {
std::cout << obj.to_string() << std::endl;
}

template <typename T>
typename std::enable_if<!has_to_string_v<T>, void>::type
print_to_string(const T&) {
std::cout << "No to_string method available" << std::endl;
}

int main() {
A a;
B b;
C c;

print_to_string(a); // Prints "Class A"
print_to_string(b); // Prints "No to_string method available"
print_to_string(c); // Prints "No to_string method available"

return 0;
}

the punishment if you fail: we will call you lil techno for a week

if you succeeded: i will make my banner whatever you want and i will make an apology thread and give my loyalty to you to the rest of my life
What the fuck is all this shit? I'm not doing any of this. I don't even know what the fuck you're talking about lol.

@TechnoBoss revealed to me in PM's that he is classified as "illiterate" 😢
No u

He probably likes techo music because hes edgy and shiet
It's not edgy to like techno music. I have techno in my name because I mix techno music on my FLX4 as a hobby.
 
  • JFL
  • +1
Reactions: Deleted member 74849, try2beme, ryuken and 2 others
Power tripping subhuman dog
 
  • JFL
  • +1
Reactions: etherwake, seanonigger, Deleted member 23974 and 1 other person
What the fuck is all this shit? I'm not doing any of this. I don't even know what the fuck you're talking about lol.
Funny GIF
 
  • +1
  • JFL
Reactions: etherwake, seanonigger and ryuken
  • Woah
Reactions: Deleted member 67738
What the fuck is all this shit? I'm not doing any of this. I don't even know what the fuck you're talking about lol.


No u


It's not edgy to like techno music. I have techno in my name because I mix techno music on my FLX4 as a hobby.
<a dog
 
  • +1
Reactions: etherwake and seanonigger
  • +1
  • JFL
Reactions: etherwake, seanonigger and ryuken
Anyway, @TechnoBoss frauds less than that subhuman of @Darkeningstar
He is not a star, he is not "darkening", jfl edgy. He is a buffoon.
 
  • So Sad
Reactions: TechnoBoss, ryuken and Deleted member 67738
Anyway, @TechnoBoss frauds less than that subhuman of @Darkeningstar
He is not a star, he is not "darkening", jfl edgy. He is a buffoon.
we love you bhai:(
 
  • JFL
Reactions: Deleted member 74849
@TechnoBoss it was a joke thread btw
 
  • JFL
Reactions: Deleted member 67738, Deleted member 74849 and TechnoBoss
It was an ironic post and I got 3 so sad
 
  • JFL
Reactions: ryuken

Similar threads

androgenic
Replies
100
Views
3K
TiktokUser
TiktokUser
Jason Voorhees
Replies
153
Views
4K
einzigartig
einzigartig
chromednash
Replies
19
Views
428
quan1
quan1
Nodesbitch
Replies
74
Views
1K
Nodesbitch
Nodesbitch

Users who are viewing this thread

Back
Top