Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YesNoにoperator==を追加 #1282

Open
wants to merge 1 commit into
base: v6_develop
Choose a base branch
from
Open

Conversation

m4saka
Copy link
Contributor

@m4saka m4saka commented Jan 4, 2025

同一タグのYesNoの値同士が等しいかどうかの比較が可能になるよう、YesNoにoperator==を追加しました。

サンプルコード:

# include <Siv3D.hpp>

using YN = YesNo<struct YN_tag>;
using AnotherYN = YesNo<struct AnotherYN_tag>;

void Main()
{
	YN a = YN::Yes;
	YN b = YN::No;
	AnotherYN c = AnotherYN::Yes;

	// YesNo同士の比較(従来はコンパイルエラー)
	Print << (a == b); // false
	Print << (a != b); // true

	// YesNoとHelperの比較(従来はコンパイルエラー)
	Print << (a == YN::Yes); // true
	Print << (a != YN::Yes); // false
	Print << (b == YN::No); // true
	Print << (b != YN::No); // false

	// 異なるTagのYesNoとの比較は従来通りコンパイルエラーのまま
	//Print << (a == c);
	//Print << (a == AnotherYN::Yes);

	while (System::Update())
	{
	}
}

実行結果:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant