Skip to content

Instantly share code, notes, and snippets.

@StarJade-Park
Created January 7, 2020 15:56
Show Gist options
  • Save StarJade-Park/667ab742c03cbfe334de81bb8cc2f5a4 to your computer and use it in GitHub Desktop.
Save StarJade-Park/667ab742c03cbfe334de81bb8cc2f5a4 to your computer and use it in GitHub Desktop.
// stl의 conditional, conditional_type을 현재 사용중인 컨벤션에 맞춰 이름만 수정한 버전임.
#pragma once
// Struct template conditional
// - type is
// - 1. Type_1 for Expression
// - 2. Type_2 for assumed !Expression
template<bool Expression, class Type_1, class Type_2>
struct TConditional
{
using type = Type_2;
};
// Struct template conditional
// - type is
// - 1. Type_1 for Expression
// - 2. Type_2 for assumed !Expression
template<class Type_1, class Type_2>
struct TConditional<true, Type_1, Type_2>
{
using type = Type_1;
};
template<bool Expression, class Type_1, class Type_2>
using TConditionalType = typename TConditional<Expression, Type_1, Type_2>::type;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment